I am using Ruby on Rails 3.2.2 and I would like to know how to retrieve the URL of the current browsed Web page in my application and to add to it some query parameter. That is, given a user is browsing the page http://www.my_application_name.org/articles/2, I would like to “build” something like link_to http://www.my_application_name.org/articles/2?param1=abc¶m2=efg.
How can / should / could I make that?
You can use the
url_formethod and pass a ruby hash to add query parameters to current URL. For example,That should work.
If you want to get the current URL with
host,portetc., you can use therequestobject to construct one as shown below.