cialis online pharmacy generic xenical cheap cialis online cialis generic viagra online in canada buy cheap levitra online cialis without a perscription order viagra uk no prescription flagyl cheap generic levitra buying viagra in the uk cheap viagra approved cialis deltasone online buy viagra online without prescription non prescription cialis buy orlistat uk buy cialis in india prednisone 60 mg female viagra online buy viagra without prescription celebrex prescriptions buy cialis canada best prices viagra alternative to prednisone cheapest generic levitra levitra 5mg cheap viagra cialis on line buy xenical without prescription online accutane canadian health care prednisone no prescreption viagra online generic female viagra europe buy cialis low price cheap india viagra

Quickly Convert Hash Into URL Query

Here’s a rather quick and very short helpful Ruby trick that some of you might be interested in incorporating to your current or next project. It’s basically a snippet that makes use of the to_query method that’ll allow you to quickly convert a hash of values into a URL string.

ruby programming tutorial

"" + { language: "ruby", status: "awesome" }.to_query
# => ""     

And if you’d like to do it the other way around (in vice versa), you can use CGI.parse like so:

require 'cgi' # Only needed for IRB, Rails already has this loaded
CGI::parse "language=ruby&status=awesome"
# => {"language"=>["ruby"], "status"=>["awesome"]}

Both methods are said to support nested values. Credit and thanks goes to Victor Solis, the fellow who originally shared this nice trick.



Related Posts

Adding Instagram Badges to Your WordPress Profile

How to Create a Custom WordPress Registration Form with Flat UI

How to Create A Basic Hipster-Style Layout

How to Style Nav Links Using Floats With HTML5 and CSS3