Created
September 28, 2011 12:28
-
-
Save unnitallman/1247809 to your computer and use it in GitHub Desktop.
Adding query string to a url
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
>> callback = Addressable::URI.parse("http://unni.com") | |
=> #<Addressable::URI:0x810ab0b4 URI:http://unni.com> | |
>> callback.query_values = callback.query_values ? callback.query_values.merge({"angry" => "birds"}) : {"angry" => "birds"} | |
=> {"angry"=>"birds"} | |
>> callback.to_s | |
=> "http://unni.com?angry=birds" | |
>> callback = Addressable::URI.parse("http://unni.com?nikhil=krishna") | |
=> #<Addressable::URI:0x8109fc8c URI:http://unni.com?nikhil=krishna> | |
>> callback.query_values = callback.query_values ? callback.query_values.merge({"angry" => "birds"}) : {"angry" => "birds"} | |
=> {"angry"=>"birds", "nikhil"=>"krishna"} | |
>> callback.to_s | |
=> "http://unni.com?angry=birds&nikhil=krishna" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment