Last active
January 3, 2016 22:29
-
-
Save geraudmathe/8528351 to your computer and use it in GitHub Desktop.
create a url dynamically
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
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¶m_2=value_2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment