instance method
to_query
Ruby on Rails 4.0.13
Since v3.0.20Signature
to_query(key)
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') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding"
Parameters
-
keyreq
Source
# File activesupport/lib/active_support/core_ext/object/to_query.rb, line 47
def to_query(key)
prefix = "#{key}[]"
collect { |value| value.to_query(prefix) }.join '&'
end
Defined in activesupport/lib/active_support/core_ext/object/to_query.rb line 47
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Array