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?

#1
How can I get the current **absolute** URL in my Ruby on Rails view?

The `request.request_uri` only returns the **relative** URL.
Reply

#2
I think request.domain would work, but what if you're in a sub directory like blah.blah.com? Something like this could work:

<%= request.env["HTTP_HOST"] + page = "/" + request.path_parameters['controller'] + "/" + request.path_parameters['action'] %>

Change the parameters based on your path structure.

Hope that helps!
Reply

#3
(url_for(:only_path => false) == "/" )? root_url : url_for(:only_path => false)
Reply

#4
If by relative, you mean just without the domain, then look into `request.domain`.


Reply

#5
I think that the Ruby on Rails 3.0 method is now `request.fullpath`.

Reply

#6
It looks like `request_uri` is deprecated in Ruby on Rails 3.

Using #request_uri is deprecated. Use fullpath instead.
Reply

#7
In Ruby on Rails 3.1.0.rc4:

request.fullpath
Reply

#8
For Ruby on Rails 3:

request.url
request.host_with_port

I fired up a debugger session and queried the request object:

request.public_methods
Reply

#9
I needed the application [URL][1] but with the subdirectory. I used:

root_url(:only_path => false)

[1]:

[To see links please register here]

Reply

#10
url_for(params)

And you can easily add some new parameter:

url_for(params.merge(:tag => "lol"))
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

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