| Class | CommentsController |
| In: |
app/controllers/comments_controller.rb
|
| Parent: | ApplicationController |
# File app/controllers/comments_controller.rb, line 23
23: def create
24: @commentable = find_commentable
25: @comment = @commentable.comments.build(params[:comment])
26: @comment.user = current_user unless current_user.nil?
27: if @comment.save
28: flash[:notice] = t(:successfully_created_comment)
29: @comment.send_later(
30: :deliver_comment_notification,
31: t(:commentable_commented, :title => @comment.commentable.list_title(60), :username => @comment.user.username),
32: "http://#{LOCALHOST_NAME}/#{@comment.commentable_type.pluralize.downcase}/#{@comment.commentable_id}"
33: )
34: respond_to do |format|
35: format.html { redirect_to @commentable }
36: format.js
37: end
38: else
39: render :action => 'new'
40: end
41: end
# File app/controllers/comments_controller.rb, line 57
57: def destroy
58: @comment = Comment.find(params[:id])
59: commentable = @comment.commentable
60: @comment.destroy
61: flash[:notice] = "Successfully destroyed comment."
62: respond_to do |format|
63: format.html { redirect_to commentable }
64: end
65: end
# File app/controllers/comments_controller.rb, line 43
43: def edit
44: @comment = Comment.find(params[:id])
45: end
# File app/controllers/comments_controller.rb, line 5
5: def index
6: unless params[:user_id]
7: @comments = Comment.descend_by_updated_at.paginate(:page => params[:page], :per_page => POSTINGS_PER_PAGE)
8: else
9: @user = User.find(params[:user_id])
10: @comments = @user.comments.descend_by_updated_at.paginate(:page => params[:page], :per_page => POSTINGS_PER_PAGE)
11: end
12: end
# File app/controllers/comments_controller.rb, line 19
19: def new
20: @comment = Comment.new
21: end
# File app/controllers/comments_controller.rb, line 14
14: def show
15: @comment = Comment.find(params[:id])
16: redirect_to @comment.commentable if @comment.commentable
17: end