mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #7915 from frodsan/docs_permit
update AC::Parameters#permit documentation [ci skip]
This commit is contained in:
commit
fc5a3e9411
1 changed files with 22 additions and 0 deletions
|
@ -171,6 +171,28 @@ module ActionController
|
||||||
# permitted[:person][:age] # => nil
|
# permitted[:person][:age] # => nil
|
||||||
# permitted[:person][:pets][0][:name] # => "Purplish"
|
# permitted[:person][:pets][0][:name] # => "Purplish"
|
||||||
# permitted[:person][:pets][0][:category] # => nil
|
# permitted[:person][:pets][0][:category] # => nil
|
||||||
|
#
|
||||||
|
# Note that if you use +permit+ in a key that points to a hash,
|
||||||
|
# it won't allow all the hash. You also need to specify which
|
||||||
|
# attributes inside the hash should be whitelisted.
|
||||||
|
#
|
||||||
|
# params = ActionController::Parameters.new({
|
||||||
|
# person: {
|
||||||
|
# contact: {
|
||||||
|
# email: 'none@test.com'
|
||||||
|
# phone: '555-1234'
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# })
|
||||||
|
#
|
||||||
|
# params.require(:person).permit(:contact)
|
||||||
|
# # => {}
|
||||||
|
#
|
||||||
|
# params.require(:person).permit(contact: :phone)
|
||||||
|
# # => {"contact"=>{"phone"=>"555-1234"}}
|
||||||
|
#
|
||||||
|
# params.require(:person).permit(contact: [ :email, :phone ])
|
||||||
|
# # => {"contact"=>{"email"=>"none@test.com", "phone"=>"555-1234"}}
|
||||||
def permit(*filters)
|
def permit(*filters)
|
||||||
params = self.class.new
|
params = self.class.new
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue