instance method to_query

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

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

key req
Source
# File activesupport/lib/active_support/core_ext/array/conversions.rb, line 53
        def to_query(key)
          prefix = "#{key}[]"
          collect { |value| value.to_query(prefix) }.join '&'
        end

Defined in activesupport/lib/active_support/core_ext/array/conversions.rb line 53 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::CoreExtensions::Array::Conversions

Type at least 2 characters to search.

↑↓ navigate · open · esc close