How to get current absolute URL in Ruby on Rails?

Ways to receive a current absolute URL for different Rails versions
22 August 2017   16183

Let's check how to get a the current absolute URL in your Ruby on Rails view, for any Rails version. 

For Rails 3.2 or Rails 4+

You should use request.original_url to get the current URL.

This method is documented at original_url method, but if you're curious, the implementation is:

def original_url
  base_url + original_fullpath

For Rails 3

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_url. This combines the protocol with the host, and request_url to give you the full address.

Ruby/RoR News Digest 30.11 - 6.12

Using Rubyfmt with Atom, overpacking as a common Webpacker mistake, RubyConf 2019 Tony Drake's speech and more 
06 December 2019   139

Greetings! I hope your week went great! Here's new Ruby news digest.

Learn about Ruby 2.7's shorthand syntax for argument forwarding, what's new in Ruby 2.7, Ruby 2019 main takeaways from the keynote (as a text) and much more!


  • Ruby 2.7 Adds Shorthand Syntax for Argument Forwarding 

In Ruby 2.7 you can use the syntax ... in parameter or argument lists to basically ‘pass through’ (or forward) arguments from one method to another

  • Using Rubyfmt with Atom

Rubyfmt is inspired by Go’s gofmt formatting tool and it formats existing Ruby code, and you can set this up as you like 

  • From ActiveRecord Callbacks to Publish/Subscribe Pattern and Event-driven Design

Learn how to move the legacy app from the old design to the new clean way, from activerecord callbacks to event-drive design, in the end

  • Overpacking.. A Common Webpacker Mistake

Learn about the popular Webpacker users' mistake and how to avoid it and save deploy time

  • Ruby - raise or raise Exception - they're both the same

Learn why they are the same


  • What’s New in Ruby 2.7? 

There’s a lot new things coming in 2.7 including controversial stuff like pattern matching, numbered parameters, and keyword argument changes

  • Rubyconf 2019 — Main takeaways from the keynote — Ruby 2.7, 3.0 and the road ahead

If you missed the biggest Ruby event this year - don't worry and check this takeaway

  • A Q&A with Eileen Uchitelle

Interview with staff Software Engineer on the Ruby Architecture Team at GitHub and a member of the Rails Core team.


  • RubyConf 2019 - JRuby: Zero to Scale!  by Charles Oliver Nutter and Thomas E Enebo

  • RubyConf 2019 - Containerizing Local Development... Is It Worth it? by Tony Drake