Class: CommentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



3
4
5
6
7
8
9
# File 'app/controllers/comments_controller.rb', line 3

def create
  @post = Post.find(params[:post_id])
  @comment = @post.comments.build(params[:comment])
  flash[:alert] = 'Fail to receive the comment. Double check the fields' unless @comment.save

  redirect_to @post
end