Created
December 21, 2009 21:24
-
-
Save joonyou/261254 to your computer and use it in GitHub Desktop.
hash to param
This file contains 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
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