So previously we set up Rails, and in this post we are going to go over how you would update to the latest Rails release.

This will be a really short article, as all we need to do is enter the following lines, and we will install Rails 8.1.3 (check rubyonrails.org for the latest version).

Once Rails has been updated we need to tell rbenv about the new executable by rehashing.

gem install rails -v 8.1.3

rbenv rehash

# version should be >= Rails 8.1.3
rails -v

That covers the gem itself. For an existing app, updating is a two-step job: bump the version in your Gemfile,

gem "rails", "~> 8.1"

then run

bundle update rails
bin/rails app:update

app:update walks you through any config files that have changed between versions - take the diff option (d) on anything you have edited yourself, like config/routes.rb.

One thing worth knowing since Rails 7.1: config/application.rb has a config.load_defaults line. After upgrading, Rails generates a new_framework_defaults_8_1.rb file so you can flip new behaviours on one at a time before bumping load_defaults itself. Much less scary than the all-at-once upgrades of old.

Not as bad as you thought? Well, why make things harder than they need to be.