Skip to content

Instantly share code, notes, and snippets.

@geraudmathe
Last active January 3, 2016 22:29
Show Gist options
  • Save geraudmathe/8528351 to your computer and use it in GitHub Desktop.
Save geraudmathe/8528351 to your computer and use it in GitHub Desktop.
create a url dynamically
url = "http://www.google.com"
params_hash = {:param_1=>"value_1", :param_2=>"value_2"}
parameterized = params_hash.map{ |k,v| "#{k}=#{v}" }.join("&")
[url, "?", parameterized].join #=> http://www.google.com?param_1=value_1&param_2=value_2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment