request.url returns me this : http://localhost:3000/page?foo=bar.
Is there a method I can call to get http://localhost:3000/page , or do I have to parse the string to strip get parameters?
What is the best way to get the current request URL in Rails? You should use request. original_url to get the current URL.
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.
You should use request. original_url to get the current URL. For Rails 3: You can write "#{request.
Rails' params hash contains any request parameters (URL parameters or request payload) as well as routing parameters like :controller , :action , or :id . To access only URL parameters, use request. query_parameters . Routing params are available through request.
request.path
should return what you're looking for if you're not concerned about the hostname. Otherwise you might try:
url_for(:only_path => false, :overwrite_params=>nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With