Class: Blogit::Admin::CommentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/blogit/admin/comments_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

blogit_conf, #blogit_conf

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/blogit/admin/comments_controller.rb', line 11

def create
  @comment = post.comments.new(comment_params)

  respond_to do |format|
    format.js {
      # the rest is dealt with in the view
      @comment.save
    }

    format.html {
      if @comment.save
        redirect_to(post, notice: t(:successfully_added_comment, scope: 'blogit.comments'))
      else
        render "blogit/posts/show"
      end
    }

  end

end

#destroyObject



32
33
34
35
36
37
38
39
# File 'app/controllers/blogit/admin/comments_controller.rb', line 32

def destroy
  @comment = post.comments.find(params[:id])
  @comment.destroy
  respond_to do |format|
    format.html { redirect_to(post, notice: t(:successfully_removed_comment, scope: 'blogit.comments'))}
    format.js
  end
end