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.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/guides/code/getting_started/app/controllers/comments_controller.rb b/guides/code/getting_started/app/controllers/comments_controller.rb
index cf3d1be42e..b2d9bcdf7f 100644
--- a/guides/code/getting_started/app/controllers/comments_controller.rb
+++ b/guides/code/getting_started/app/controllers/comments_controller.rb
@@ -1,9 +1,10 @@
class CommentsController < ApplicationController
- http_basic_authenticate_with :name => "dhh", :password => "secret", :only => :destroy
+
+ http_basic_authenticate_with name: "dhh", password: "secret", only: :destroy
def create
@post = Post.find(params[:post_id])
- @comment = @post.comments.create(params[:comment])
+ @comment = @post.comments.create(comment_params)
redirect_to post_path(@post)
end
@@ -14,4 +15,9 @@ class CommentsController < ApplicationController
redirect_to post_path(@post)
end
+ private
+
+ def comment_params
+ params.require(:comment).permit(:commenter, :body)
+ end
end