Created
January 11, 2011 07:07
-
-
Save charlie/774142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hash_to_params(hash) | |
hash.keys.inject("") do |qs, key| | |
qs << "&" unless qs.blank? | |
qs << if Array === hash[key] | |
k = CGI.escape(key.to_s) | |
hash[key].map { |value| "#{k}=" << CGI.escape(value.to_s) }.join("&") | |
else | |
CGI.escape(key.to_s) << "=" << CGI.escape(hash[key].to_s) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment