From 10dec0e65e1f4d87f411b4361045eba86b121be9 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 28 Sep 2010 00:32:20 +0200 Subject: 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. --- activesupport/lib/active_support/core_ext/object/to_param.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'activesupport/lib') 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 namespace 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 -- cgit v1.2.3