to_query(key)
public
Converts an array into a string suitable for use as a URL query string,
using the given key as the param name.
['Rails', 'coding'].to_query('hobbies')
# File activesupport/lib/active_support/core_ext/object/to_query.rb, line 50
def to_query(key)
prefix = "#{key}[]"
if empty?
nil.to_query(prefix)
else
collect { |value| value.to_query(prefix) }.join "&"
end
end