aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-03-07 22:20:24 +0100
committerXavier Noria <fxn@hashref.com>2011-03-07 22:20:24 +0100
commita0d7247d1509762283c61182ad82c2eed8d54757 (patch)
tree7eaa881c92b8116c1ac699f57f737f533d93c781 /activesupport/lib
parent89ecc0a5dc1d06a6bbd2a59edd57187c6eedf8af (diff)
downloadrails-a0d7247d1509762283c61182ad82c2eed8d54757.tar.gz
rails-a0d7247d1509762283c61182ad82c2eed8d54757.tar.bz2
rails-a0d7247d1509762283c61182ad82c2eed8d54757.zip
reorganizes the RDoc of Hash#to_param
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/object/to_param.rb20
1 files changed, 14 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 5e0ad4d1cf..e5f81078ee 100644
--- a/activesupport/lib/active_support/core_ext/object/to_param.rb
+++ b/activesupport/lib/active_support/core_ext/object/to_param.rb
@@ -32,13 +32,21 @@ class Array
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). The string pairs "key=value" that conform the query
- # string are sorted lexicographically in ascending order. This method is also aliased as <tt>to_query</tt>.
+ # Returns a string representation of the receiver suitable for use as a URL
+ # query string:
#
- # ==== Examples
- # { :name => 'David', :nationality => 'Danish' }.to_param # => "name=David&nationality=Danish"
- # { :name => 'David', :nationality => 'Danish' }.to_param('user') # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish"
+ # {:name => 'David', :nationality => 'Danish'}.to_param
+ # # => "name=David&nationality=Danish"
+ #
+ # An optional namespace can be passed to enclose the param names:
+ #
+ # {:name => 'David', :nationality => 'Danish'}.to_param('user')
+ # # => "user[name]=David&user[nationality]=Danish"
+ #
+ # The string pairs "key=value" that conform the query string
+ # are sorted lexicographically in ascending order.
+ #
+ # This method is also aliased as +to_query+.
def to_param(namespace = nil)
collect do |key, value|
value.to_query(namespace ? "#{namespace}[#{key}]" : key)