aboutsummaryrefslogtreecommitdiffstats
path: root/guides/code/getting_started/app/controllers/comments_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'guides/code/getting_started/app/controllers/comments_controller.rb')
-rw-r--r--guides/code/getting_started/app/controllers/comments_controller.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/guides/code/getting_started/app/controllers/comments_controller.rb b/guides/code/getting_started/app/controllers/comments_controller.rb
index 0e3d2a6dde..b2d9bcdf7f 100644
--- a/guides/code/getting_started/app/controllers/comments_controller.rb
+++ b/guides/code/getting_started/app/controllers/comments_controller.rb
@@ -4,7 +4,7 @@ class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
- @comment = @post.comments.create(params[:comment].permit(:commenter, :body))
+ @comment = @post.comments.create(comment_params)
redirect_to post_path(@post)
end
@@ -14,4 +14,10 @@ class CommentsController < ApplicationController
@comment.destroy
redirect_to post_path(@post)
end
+
+ private
+
+ def comment_params
+ params.require(:comment).permit(:commenter, :body)
+ end
end