Created
February 12, 2013 00:24
-
-
Save ndbroadbent/4758944 to your computer and use it in GitHub Desktop.
Save this to config/initializers/json_munging_patch.rb until https://github.com/rails/rails/pull/8862 or an alternative fix is merged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Patch from https://github.com/rails/rails/pull/8862 | |
module ActionDispatch | |
Request.class_eval do | |
# Remove nils from the params hash | |
def deep_munge(hash) | |
hash.each do |k, v| | |
case v | |
when Array | |
if v.size > 0 && v.all?(&:nil?) | |
hash[k] = nil | |
next | |
end | |
v.grep(Hash) { |x| deep_munge(x) } | |
v.compact! | |
when Hash | |
deep_munge(v) | |
end | |
end | |
hash | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ndbroadbent seem like this wasn't applied?