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.
Written by Rajeev N Bharshetty
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#