diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-04 18:29:31 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-04 18:29:31 -0300 |
commit | b4b0d9d1c1b2c0012dbd5186341b3def2e2c9052 (patch) | |
tree | a750781b9581d322cc33534c85b1336b424408c0 /activesupport/lib/active_support | |
parent | cf0dc18ac34f45f0fd0aa231c0e59c994691d90f (diff) | |
parent | 41bbac6ff4d161fc94ef2dc601e06f0a2779dbaf (diff) | |
download | rails-b4b0d9d1c1b2c0012dbd5186341b3def2e2c9052.tar.gz rails-b4b0d9d1c1b2c0012dbd5186341b3def2e2c9052.tar.bz2 rails-b4b0d9d1c1b2c0012dbd5186341b3def2e2c9052.zip |
Merge pull request #14949 from bogdan/empty-hash-array-parameterization
[Fixes #14948] Hash#to_query: right serialization for empty hash and array
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/to_param.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/to_param.rb b/activesupport/lib/active_support/core_ext/object/to_param.rb index 13be0038c2..0611eb819d 100644 --- a/activesupport/lib/active_support/core_ext/object/to_param.rb +++ b/activesupport/lib/active_support/core_ext/object/to_param.rb @@ -51,12 +51,12 @@ class Hash # # This method is also aliased as +to_query+. def to_param(namespace = nil) - if empty? - namespace ? nil.to_query(namespace) : '' - else - collect do |key, value| + collect do |key, value| + unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty? value.to_query(namespace ? "#{namespace}[#{key}]" : key) - end.sort! * '&' - end + else + nil + end + end.compact.sort! * '&' end end |