Skip to content

Commit

Permalink
Add explanation about accepts_nested_attributes_for keys in the stron…
Browse files Browse the repository at this point in the history
…g parameters documentation [skip ci]
  • Loading branch information
bdewater committed Mar 12, 2016
1 parent 9201030 commit 9a0fc9a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions actionpack/lib/action_controller/metal/strong_parameters.rb
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 9a0fc9a

Please sign in to comment.