diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-02-06 01:03:41 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-02-06 01:03:41 -0200 |
commit | c82dbc6a1c1a269fb21de8fd2722fc680ab7ea54 (patch) | |
tree | ec2733feb27a4102ec3707fb5e09b53a6156b182 /activesupport/lib/active_support | |
parent | 7aa4b7dc6bd6ecea1f5009c5549ea69dd59d96d4 (diff) | |
download | rails-c82dbc6a1c1a269fb21de8fd2722fc680ab7ea54.tar.gz rails-c82dbc6a1c1a269fb21de8fd2722fc680ab7ea54.tar.bz2 rails-c82dbc6a1c1a269fb21de8fd2722fc680ab7ea54.zip |
Fix to_query with empty arrays too
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/to_query.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/to_query.rb b/activesupport/lib/active_support/core_ext/object/to_query.rb index 5d5fcf00e0..37352fa608 100644 --- a/activesupport/lib/active_support/core_ext/object/to_query.rb +++ b/activesupport/lib/active_support/core_ext/object/to_query.rb @@ -18,7 +18,12 @@ class Array # ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding" def to_query(key) prefix = "#{key}[]" - collect { |value| value.to_query(prefix) }.join '&' + + if empty? + nil.to_query(prefix) + else + collect { |value| value.to_query(prefix) }.join '&' + end end end |