Last Updated: February 25, 2016
·
3.465K
· rshetty

to_query - Hash to URL

Got a Hash of Values which have to be included in the URL String (As options) .
You can use ActiveSupport provided 'to_query' method to convert the hash of values into query string and include it in the url.

Example :

URL :

"www.rubyawesome.com?" + { language: 'ruby', page: 'best' }.to_query 

OUTPUT :

"www.rubyawesome.com?language=ruby&page=best"

Thats it.