# File guides/code/getting_started/app/controllers/comments_controller.rb, line 5 def create @post = Post.find(params[:post_id]) @comment = @post.comments.create(comment_params) redirect_to post_path(@post) end
# File guides/code/getting_started/app/controllers/comments_controller.rb, line 11 def destroy @post = Post.find(params[:post_id]) @comment = @post.comments.find(params[:id]) @comment.destroy redirect_to post_path(@post) end
# File guides/code/getting_started/app/controllers/comments_controller.rb, line 20 def comment_params params.require(:comment).permit(:commenter, :body) end