Permalink
Browse files

Missed commit. References #10395.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8344 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 2d2fd67 commit 62ddeaf0522a00d1040d19d616238fa47177ba64 @jeremy jeremy committed Dec 9, 2007
Showing with 14 additions and 0 deletions.
  1. +14 −0 activesupport/lib/active_support/core_ext/object/conversions.rb
@@ -0,0 +1,14 @@
+class Object
+ # Alias of <tt>to_s</tt>.
+ def to_param
+ to_s
+ end
+
+ # Converts an object into a string suitable for use as a URL query string, using the given <tt>key</tt> as the
+ # param name.
+ #
+ # Note: This method is defined as a default implementation for all Objects for Hash#to_query to work.
+ def to_query(key)
+ "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}"
+ end
+end

0 comments on commit 62ddeaf

Please sign in to comment.