This is my new way of learning and promoting my intelligence in Ruby. My intention is to create a new Ruby tip everyday. These tips will come from all places and will certainly involve examples from work and frameworks.

Here is a cool way of creating a link in Rails:

"http://www.example.com?" + { language: "ruby", status: "awesome" }.to_query
# => "http://www.example.com?language=ruby&status=awesome"

or without Rails require CGI

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

I learned this from: http://rubyquicktips.com/post/29682077100/quick-hash-to-a-url-query-trick

Leave a Reply

Your email address will not be published. Required fields are marked *