Module ActiveSupport::CoreExtensions::Array::Conversions
In: lib/active_support/core_ext/array/conversions.rb

Methods

Public Instance methods

Calls to_param on all its elements and joins the result with slashes. This is used by url_for in Action Pack.

Converts an array into a string suitable for use as a URL query string, using the given key as the param name.

Example:

  ['Rails', 'coding'].to_query('hobbies') => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding"

Converts the array to a comma-separated sentence where the last element is joined by the connector word. Options:

  • :connector - The word used to join the last element in arrays with two or more elements (default: "and")
  • :skip_last_comma - Set to true to return "a, b and c" instead of "a, b, and c".

[Validate]