On 12 Mar., 18:19, Miguel Regedor <
miguelrege...@gmail.com> wrote:
> to_param and to_query, what's the difference between those methods?
If you are refering to the Array class which has been extended with
the two methods #to_param and #to_query, I can tell you that #to_param
calls #to_param calls on all its contained elements and joins them
with a slash. In contrast #to_query calls #to_query on all contained
elements, prefixes them with the first argument ('key') plus [] and
joins it all with an ampersand.
['hello', 'great', 'world'].to_param # => hello/great/world
['hello', 'great', 'world'].to_query('words') # => words%5B
%5D=hello&words%5B%5D=great&words%5B%5D=world
#to_param is used after the question mark in a URI, #to_query after.
Hope it makes things clear. :)
--
Cheers,
David Knorr
http://twitter.com/rubyguy