Rails Current View Absolute Path Relative Path Output

Getting Absolute and Relative Paths of Current View in Rails

This article introduces how to output the absolute and relative paths of the current view in Rails. We are using Ruby on Rails 5, but please note that specifications may differ depending on the version.

Shou Arisaka
1 min read
Nov 17, 2025

Getting Absolute and Relative Paths of Current View in Rails

When using Ruby on Rails, this article introduces how to output the absolute and relative paths of the current view. This article targets Ruby on Rails 5, but if youโ€™re using a different version or encounter errors, please refer to the official documentation.

How to Get Absolute Path

To get the absolute path, use request.original_url. This returns the complete URL.

# Absolute path
request.original_url # => https://www.example.com/users/sign_in

How to Get Relative Path

To get the relative path, use request.fullpath. This returns only the path portion without the hostname.

# Relative path
request.fullpath # => /users/sign_in

By using these methods, you can easily retrieve the URL information of the current view. This is often useful during Rails application development, so please make use of it.

Share this article

Shou Arisaka Nov 17, 2025

๐Ÿ”— Copy Links