Let's check how to get a the current absolute URL in your Ruby on Rails view, for any Rails version.
For Rails 3.2 or Rails 4+
You should use
request.original_url to get the current URL.
This method is documented at
original_url method, but if you're curious, the implementation is:
def original_url base_url + original_fullpath end
For Rails 3
request.url is now deprecated.
For Rails 2
You can write
request.url instead of
request.request_url. This combines the protocol with the host, and
request_url to give you the full address.