Skip to content

Synchronize PostController#create code from 5.6 to others sections in Getting Started guide. #11186

Merged
merged 1 commit into from Jun 30, 2013

2 participants

@pftg
pftg commented Jun 29, 2013

Added use of post_params to other sections where Post params are used.

Connected with #11182

@senny senny commented on an outdated diff Jun 30, 2013
guides/source/getting_started.md
@@ -918,6 +933,8 @@ that already exists, and it accepts a hash containing the attributes
that you want to update. As before, if there was an error updating the
post we want to show the form back to the user.
+We use `post_params` method added before for `create` action, no need to add it again.
@senny
Ruby on Rails member
senny added a note Jun 30, 2013

Can we reword this to:

We reuse the post_params method that we defined earlier for the create action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@senny senny commented on an outdated diff Jun 30, 2013
guides/source/getting_started.md
@@ -1303,7 +1320,7 @@ Let's wire up the `create` in `app/controllers/comments_controller.rb`:
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
- @comment = @post.comments.create(params[:comment].permit(:commenter, :body))
+ @comment = @post.comments.create(params.require(:comment).permit(:commenter, :body))
@senny
Ruby on Rails member
senny added a note Jun 30, 2013

is there a specific reason not to use comment_params here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pftg
pftg commented Jun 30, 2013

Thanks @senny. I updated PR with changes based on your feedback.

@senny senny merged commit 996f9b5 into rails:master Jun 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.