aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-10-11 22:41:01 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-10-11 22:41:01 -0500
commit299fee5919ec41290421684436a50105c4ddc485 (patch)
treee8aa0c7b811b2b3c28d641cf6f3b038327b32dc3 /actionpack/lib
parentbdd105d8b91c5d0881ab78e36a65a79fdca4a7fb (diff)
downloadrails-299fee5919ec41290421684436a50105c4ddc485.tar.gz
rails-299fee5919ec41290421684436a50105c4ddc485.tar.bz2
rails-299fee5919ec41290421684436a50105c4ddc485.zip
update AC::Parameters#permit documentation [ci skip]
bdd105d changes the behaviour of AC::Parameters#permit.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index a6250f5d03..c42b3dddc9 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -171,6 +171,28 @@ module ActionController
# permitted[:person][:age] # => nil
# permitted[:person][:pets][0][:name] # => "Purplish"
# 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)
params = self.class.new