Skip to content

Commit

Permalink
Merge pull request rails#24171 from bdewater/strong_parameters_anaf_doc
Browse files Browse the repository at this point in the history
Add explanation about accepts_nested_attributes_for keys in the strong parameters docs
  • Loading branch information
pixeltrix committed Mar 12, 2016
2 parents 6039715 + 9a0fc9a commit 4928c5c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions actionpack/lib/action_controller/metal/strong_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,8 @@ def hash_filter(params, filter)
# end
#
# In order to use <tt>accepts_nested_attributes_for</tt> with Strong \Parameters, you
# will need to specify which nested attributes should be whitelisted.
# will need to specify which nested attributes should be whitelisted. You might want
# to allow +:id+ and +:_destroy+, see ActiveRecord::NestedAttributes for more information.
#
# class Person
# has_many :pets
Expand All @@ -834,7 +835,7 @@ def hash_filter(params, filter)
# # It's mandatory to specify the nested attributes that should be whitelisted.
# # If you use `permit` with just the key that points to the nested attributes hash,
# # it will return an empty hash.
# params.require(:person).permit(:name, :age, pets_attributes: [ :name, :category ])
# params.require(:person).permit(:name, :age, pets_attributes: [ :id, :name, :category ])
# end
# end
#
Expand Down

0 comments on commit 4928c5c

Please sign in to comment.