diff options
author | Xavier Noria <fxn@hashref.com> | 2010-09-28 00:32:20 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-09-28 00:32:20 +0200 |
commit | 10dec0e65e1f4d87f411b4361045eba86b121be9 (patch) | |
tree | 36d90e5f9b40c4d48d344481a895383fc7e0277c /activesupport/lib/active_support | |
parent | f22b40a8f223e0b2f5194b6f3ce24cafd5cd3a05 (diff) | |
download | rails-10dec0e65e1f4d87f411b4361045eba86b121be9.tar.gz rails-10dec0e65e1f4d87f411b4361045eba86b121be9.tar.bz2 rails-10dec0e65e1f4d87f411b4361045eba86b121be9.zip |
let Hash#to_param and Hash#to_query sort again
This was a regression introduced in 5c858220085dc4ddc1bec496747059dfbe32f1da. We bring
sorting back because people rely on it, eg for constructing consistent cache keys.
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/to_param.rb | 5 |
1 files changed, 3 insertions, 2 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 f2e7c2351e..3a18e2a121 100644 --- a/activesupport/lib/active_support/core_ext/object/to_param.rb +++ b/activesupport/lib/active_support/core_ext/object/to_param.rb @@ -35,7 +35,8 @@ end class Hash # Converts a hash into a string suitable for use as a URL query string. An optional <tt>namespace</tt> can be - # passed to enclose the param names (see example below). + # passed to enclose the param names (see example below). The keys in the query string are sorted lexicographically + # in ascending order. # # ==== Examples # { :name => 'David', :nationality => 'Danish' }.to_param # => "name=David&nationality=Danish" @@ -44,6 +45,6 @@ class Hash def to_param(namespace = nil) collect do |key, value| value.to_query(namespace ? "#{namespace}[#{key}]" : key) - end * '&' + end.sort * '&' end end |