Skip to content

Instantly share code, notes, and snippets.

@joonyou
Created December 21, 2009 21:24
Show Gist options
  • Save joonyou/261254 to your computer and use it in GitHub Desktop.
Save joonyou/261254 to your computer and use it in GitHub Desktop.
hash to param
require 'uri'
require 'yaml'
def hash_to_param(hash)
params = []
hash.each do |k,v|
params << "#{URI.escape(k)}=#{URI.escape(v)}"
end
params.join("&")
end
def yaml_string_to_param(yaml)
hash_to_param YAML.load(yaml)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment