request.referer
request.fullpath
request.fullpath.split("?")[0]
request.referer
or request.env['HTTP_REFERER']
your controller to get the referer url.
--------------------
request.original_url
request.url
request.host_with_port
<link rel="canonical" href="<%= request.url %>" />
<%=request.path%>
How can I get the current absolute URL in my Ruby on Rails view?
The request.request_uri only returns the relative URL.
request.env['REQUEST_URI']
For Rails 3.2 or Rails 4 you should use request.original_url to get the current URL. More detail.
For Rails 3: You want "#{request.protocol}#{request.host_with_port}#{request.fullpath}", since request.url is now deprecated.
For Rails 2: You want request.url instead of request.request_uri. This combines the protocol (usually http://) with the host, and request_uri to give you the full address
awesome post presented by you..your writing style is fabulous and keep update with your blogs Ruby on Rails Online Training
ReplyDelete