Class: CommentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



4
5
6
7
# File 'lib/app/controllers/comments_controller.rb', line 4

def create
  @comment = @article.comments.create(comment_params.merge(user_id: current_user.id))
  redirect_to article_path(@article)
end

#destroyObject



9
10
11
12
13
14
# File 'lib/app/controllers/comments_controller.rb', line 9

def destroy
  @comment = @article.comments.find(params[:id])

  @comment.destroy
  redirect_to article_path(@article), notice: "Comment Destroyed Successfully"
end