Class: CommentsController
- Inherits:
-
BaseController
- Object
- BaseController
- CommentsController
- Defined in:
- app/controllers/comments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/comments_controller.rb', line 33 def create @comment = @commentable.comments.build(comment_params) if @comment.save trigger_events @comment CommentMailer.comment_notification(@comment).deliver_later if current_user.anonymous? flash.notice = "Your comment is being reviewed, and will be posted shortly. Thank you for commenting!" else @comment.update_column :approved, true flash.notice = "You're an admin, so your comment is being posted immediately! Refresh the page to see it." end respond_to do |format| format.html { redirect_to "#{request.env['HTTP_REFERER']}#comments" } format.js { render json: true } end else flash[:error] = @comment.errors..to_sentence # TODO hu. respond_to do |format| format.html { redirect_to "#{request.env['HTTP_REFERER']}#comments" } format.js { render json: false } end end end |
#destroy ⇒ Object
69 70 71 72 73 |
# File 'app/controllers/comments_controller.rb', line 69 def destroy @comment.destroy trigger_events @comment redirect_to "/", notice: t(:'adva.comments.flash.destroy.success') end |
#preview ⇒ Object
27 28 29 30 31 |
# File 'app/controllers/comments_controller.rb', line 27 def preview @comment = @commentable.comments.build(comment_params) @comment.send(:process_filters) render :layout => false end |
#show ⇒ Object
24 25 |
# File 'app/controllers/comments_controller.rb', line 24 def show end |
#update ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/comments_controller.rb', line 57 def update if @comment.update(comment_params) trigger_events(@comment) flash.notice = t(:'adva.comments.flash.update.success') render json: true else set_commentable flash[:error] = @comment.errors..to_sentence render json: false end end |