Friday, August 12, 2016

How to get the current absolute URL in Rails

Absolute URL in Rails

In Rails 5, you can use:


Assuming, the request is:

get "/articles?page=2"

This will return:

This is defined in actionpack/lib/action_dispatch/http/request.rb.

Full path without the URL

For this request:

get "/articles"


will return:


For a request with params in the URL:

get "/articles?page=2"

It will return:


No comments:

Post a Comment