diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-06-10 22:44:54 -0500 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-06-12 14:07:29 -0700 |
commit | 24894fc13037e849bceb3e1999bf41326f5d8077 (patch) | |
tree | 1fbf14b298a629ff0b80b9f78b78667e14c6bceb /actionpack/lib/action_dispatch | |
parent | 65d584c35b97c57079cb788e375685dd5e2e787c (diff) | |
download | rails-24894fc13037e849bceb3e1999bf41326f5d8077.tar.gz rails-24894fc13037e849bceb3e1999bf41326f5d8077.tar.bz2 rails-24894fc13037e849bceb3e1999bf41326f5d8077.zip |
Array parameters should not contain nil values.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/http/request.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index 6757a53bd1..65ff6fb7d8 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -267,17 +267,19 @@ module ActionDispatch # Remove nils from the params hash def deep_munge(hash) + keys = hash.keys.find_all { |k| hash[k] == [nil] } + keys.each { |k| hash[k] = nil } + hash.each_value do |v| case v when Array v.grep(Hash) { |x| deep_munge(x) } + v.compact! when Hash deep_munge(v) end end - keys = hash.keys.find_all { |k| hash[k] == [nil] } - keys.each { |k| hash[k] = nil } hash end |