Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
ext/active_support/core_ext/object/to_query.rb

Instance Method Summary collapse

Instance Method Details

#to_query(namespace = nil) ⇒ Object Also known as: to_param



11
12
13
14
15
16
17
# File 'ext/active_support/core_ext/object/to_query.rb', line 11

def to_query(namespace = nil)
  collect do |key, value|
    # unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
      value.to_query(namespace ? "#{namespace}[#{key}]" : key)
    # end
  end.compact.sort! * '&'
end