Skip to content

Instantly share code, notes, and snippets.

@mostlyfine
Created November 22, 2010 10:21
Show Gist options
  • Select an option

  • Save mostlyfine/709780 to your computer and use it in GitHub Desktop.

Select an option

Save mostlyfine/709780 to your computer and use it in GitHub Desktop.
Converts an hash object into a string suitable for use as a URL query string, using the given key as the param name.
def queryize(hash)
require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
hash.map{|i| i.map {|j| CGI.escape j.to_s}.join('=') }.join('&')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment