aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/request.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-06-10 22:44:54 -0500
committerAaron Patterson <aaron.patterson@gmail.com>2012-06-11 14:00:05 -0700
commit38edea0c912f19b5c6a689465be71b29d9da101d (patch)
tree0d071b4619e1642df0c221d82f2cc589e715184b /actionpack/lib/action_dispatch/http/request.rb
parentcc2903da9f13c26ba3d94c149f31d4c53b94b2ed (diff)
downloadrails-38edea0c912f19b5c6a689465be71b29d9da101d.tar.gz
rails-38edea0c912f19b5c6a689465be71b29d9da101d.tar.bz2
rails-38edea0c912f19b5c6a689465be71b29d9da101d.zip
Array parameters should not contain nil values.
Diffstat (limited to 'actionpack/lib/action_dispatch/http/request.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb6
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 adbb5d1346..afc0496ef9 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -251,17 +251,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