Class: Array
Instance Method Summary collapse
-
#to_query(key) ⇒ Object
Converts an array into a string suitable for use as a URL query string, using the given
keyas the param name.
Instance Method Details
#to_query(key) ⇒ Object
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"
20 21 22 23 |
# File 'lib/droiuby/support/to_query.rb', line 20 def to_query(key) prefix = "#{key}[]" collect { |value| value.to_query(prefix) }.join '&' end |