From 53f12b073cc238757431708e6730e60b10b4d5fe Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Sun, 7 Jul 2013 13:43:24 +0100 Subject: Refactored strong paramters usage and updated Gemfile.lock with Rails 4 --- .../code/getting_started/app/controllers/comments_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'guides/code/getting_started/app/controllers/comments_controller.rb') 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 -- cgit v1.2.3