diff options
author | kennyj <kennyj@gmail.com> | 2013-09-22 23:57:21 +0900 |
---|---|---|
committer | kennyj <kennyj@gmail.com> | 2013-09-27 03:53:45 +0900 |
commit | 277918e61afaec64c1378194ea272f938beaa8ad (patch) | |
tree | 5891cf80bc812825e0bcfa06b43a48d2c5da60b2 /actionpack/lib/action_controller | |
parent | 3f488d4a076ba0146535ef6e2aa9cb21a1882810 (diff) | |
download | rails-277918e61afaec64c1378194ea272f938beaa8ad.tar.gz rails-277918e61afaec64c1378194ea272f938beaa8ad.tar.bz2 rails-277918e61afaec64c1378194ea272f938beaa8ad.zip |
Strong parameters should permit nested number as key. Closes #12293
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index b495ab3f0f..66403d533c 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -334,7 +334,7 @@ module ActionController def each_element(object) if object.is_a?(Array) object.map { |el| yield el }.compact - elsif object.is_a?(Hash) && object.keys.all? { |k| k =~ /\A-?\d+\z/ } + elsif fields_for_style?(object) hash = object.class.new object.each { |k,v| hash[k] = yield v } hash @@ -343,6 +343,10 @@ module ActionController end end + def fields_for_style?(object) + object.is_a?(Hash) && object.all? { |k, v| k =~ /\A-?\d+\z/ && v.is_a?(Hash) } + end + def unpermitted_parameters!(params) unpermitted_keys = unpermitted_keys(params) if unpermitted_keys.any? |