A few notes on upgrading to Rails 6
I had the opportunity to upgrade 3 Rails apps. Here are some notes from that experience.
Upgrade guide
gem "rails", "~> 6.0.0"
# bootsnap needs to be >= 1.4.2
gem "bootsnap", ">= 1.4.2", require: false
bundle update rails
- config.load_defaults 5.2
+ config.load_defaults 6.0
This is the minimum, quite straightforward.
I prefer to also run bin/rails app:update
to get the latest configs. Although many of them can be just fixing punctuations or removing unneeded configurations, I prefer to keep config closer to what I'll get when I run a fresh rails new app
. 🙂
A few notes on rails app:update
After running rails app:update
and reviewing the changes, most looked good. I only searched a few that stand out.
- config.action_controller.perform_caching = true
One of the apps I upgraded is running on config.api_mode = true
, with that config, the app:update
command will generate this change.
This is because the config is irrelavent for api_mode
app, "because we don't provide view caching and doesn't include ActionController::Caching
for api apps." Removing this config is to avoid confusing people.
Note that it won't change the existing behavior.
Learn more: https://github.com/rails/rails/pull/36067
Next, we got this config.cache_classes
to changed to false for test.
- config.cache_classes = true
+ config.cache_classes = false
This responsibility seems to be delegated to Spring now based on this commit.
Sprockets: Lock to major version 3
When I run bundle update rails
, for two apps that have been running on Sprockets V3 got bumped to V4. That was a major upgrade, which requires you take actions. (See the upgrade guide.)
I tried to upgrade but had encountered some errors and my css won't compile. I decided to not invest anymore and reverted it back to V3 by adding this line to my Gemfile:
gem 'sprockets', '~> 3.0'
The reason being: V3 still works, and I plan to migrate all the assets to Webpack soon anyway.
You can check my previous post on Active Storage with Rails 6.
http://railsdiff.org/5.2.0/6.0.0 can also be handy.
Clap to support the author, help others find it, and make your opinion count.