Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 760 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I get the current absolute URL in Ruby on Rails?

#31
**For Rails 3.2 or Rails 4**
Simply get in this way "request.original_url"
Reference: [Original URL Method][1]

**For Rails 3**
As request.url is deprecated.We can get absolute path by concatenating

"#{request.protocol}#{request.host_with_port}#{request.fullpath}"

**For Rails 2**

request.url


[1]:

[To see links please register here]

Reply

#32
You could use `url_for(only_path: false)`
Reply

#33
### For Rails 3.2 or Rails 4+

You should use `request.original_url` to get the current URL. Source code on current repo found [here][1].

This method is documented at [original_url method](

[To see links please register here]

), but if you're curious, the implementation is:

def original_url
base_url + original_fullpath
end

-----

### For Rails 3:


You can write `"#{request.protocol}#{request.host_with_port}#{request.fullpath}"`, since `request.url` is now deprecated.

----------


### For Rails 2:

You can write `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.


[1]:

[To see links please register here]

Reply

#34
If you're using **Rails 3.2** or **Rails 4**, you should use `request.original_url` to get the current URL.


----------


Documentation for the method is at

[To see links please register here]

, but if you're curious, the implementation is:

def original_url
base_url + original_fullpath
end

**EDIT**: This is still the case for **Rails 7** ([Docs](

[To see links please register here]

)).
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through