diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2012-10-31 16:32:24 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2012-10-31 16:33:54 +0100 |
commit | 954c350daf435017e34327c83d877377c3f83778 (patch) | |
tree | d756be6db8075e75e63da13f99776eee5516b129 /actionpack | |
parent | 4b20cd9c663a417353e4d0388189af71cc642fca (diff) | |
download | rails-954c350daf435017e34327c83d877377c3f83778.tar.gz rails-954c350daf435017e34327c83d877377c3f83778.tar.bz2 rails-954c350daf435017e34327c83d877377c3f83778.zip |
Allow #permit to take its list of permitted parameters as an array
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/parameters/parameters_permit_test.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 7d5781b23a..9f78e679c6 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -196,7 +196,7 @@ module ActionController def permit(*filters) params = self.class.new - filters.each do |filter| + filters.flatten.each do |filter| case filter when Symbol, String then if has_key?(filter) diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb index ad970f0a9a..a13ffab9c0 100644 --- a/actionpack/test/controller/parameters/parameters_permit_test.rb +++ b/actionpack/test/controller/parameters/parameters_permit_test.rb @@ -1,4 +1,5 @@ require 'abstract_unit' +require 'debugger' require 'action_controller/metal/strong_parameters' class ParametersPermitTest < ActiveSupport::TestCase @@ -77,4 +78,8 @@ class ParametersPermitTest < ActiveSupport::TestCase ActionController::Parameters.permit_all_parameters = false end end + + test "permitting parameters as an array" do + assert_equal "32", @params[:person].permit([ :age ])[:age] + end end |