class Array

def to_query(key)

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

using the given +key+ as the param name.
Converts an array into a string suitable for use as a URL query string,
def to_query(key)
  prefix = "#{key}[]"
  if empty?
    nil.to_query(prefix)
  else
    collect { |value| value.to_query(prefix) }.join "&"
  end
end