0

Is there some easy way (offered by rails?) for the view to know its own url ? The one that was called to display the page.

I am able to write a helper method that will rebuild the url from the different parameters available for the controller in the params hash. But before programming such method, i was wondering if there is anything standard already.

Thanks

user3442206
  • 577
  • 1
  • 6
  • 22

2 Answers2

2

You can use request.fullpath or even request.original_url.

Take a look at the request object

apneadiving
  • 114,565
  • 26
  • 219
  • 213
1

Depends on which rails version you are using :

Rails 2 : request.url

Rails 3 and above : request.original_url -- http://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-original_url

nbirla
  • 600
  • 3
  • 14