Upgrade Rails from 6.0 to 6.1
This article is part of our Upgrade Rails series. To see more of them, click here .
This article will cover the most important aspects that you need to know to get your Ruby on Rails application from version 6.0 to 6.1 .
1. Preparations
Before beginning with the upgrade process, we have some recommended preparations:
- Your Rails app should have the latest patch version before you move to the next major/minor version.
- You should have at least 80% test coverage unless you have a dedicated QA team.
- Follow a Git flow workflow to actively manage at least two environments: staging and production.
- Check your Gemfile.lock for incompatibilities by using RailsBump .
- Create a dual boot mechanism, the fastest way to do this is installing the handy gem next_rails . Find out more about how and why to dual boot .
- To learn more about dual booting with non-backwards compatible changes you can visit this article .
For full details check out our article on How to Prepare Your App for a Rails Upgrade .
2. Ruby version
Rails 6.1 requires Ruby 2.5 or later. Check out this table to see all the required Ruby versions across all Rails versions.
3. Gems
Make sure you check the GitHub page of the gems you use for the project to find out its compatibility with Rails 6.1. In case you are the maintainer of the gem, you’ll need to make sure it supports Rails 6.1 and if it doesn’t, update it. A great site to checkout compatibility is RailsBump .
4. Config files
Rails includes the rails app:update
task .
You can use this task as a guideline as explained thoroughly in
this post .
As an alternative, check out RailsDiff , which provides an overview of the changes in a basic Rails app between 6.0.x and 6.1.x (or any other source/target versions).
5. Rails Guides
It is important to check through the official Rails Guides and follow any of the steps necessary for your application.
6. Removals
If you have ignored deprecation warnings on past version jumps, and haven’t been staying up to date with them you may find that you have issues with broken tests or broken parts of the application. If you have trouble figuring out why something is broken it may be because a deprecation is removed, so you can check through this list to see if this may be the case.
Railties
-
Remove deprecated
rake notes
tasks. -
Remove deprecated
connection
option in therails dbconsole
command. -
Remove deprecated
SOURCE_ANNOTATION_DIRECTORIES
environment variable support fromrails notes
. -
Remove deprecated
server
argument from the rails server command. -
Remove deprecated support for using the
HOST
environment variable to specify the server IP. -
Remove deprecated
rake dev:cache
tasks. -
Remove deprecated
rake routes
tasks. -
Remove deprecated
rake initializers
tasks.
Action Pack
-
Remove deprecated
ActionDispatch::Http::ParameterFilter
. -
Remove deprecated
force_ssl
at the controller level.
Action View
-
Remove deprecated
escape_whitelist
fromActionView::Template::Handlers::ERB
. -
Remove deprecated
find_all_anywhere
fromActionView::Resolver
. -
Remove deprecated
formats
fromActionView::Template::HTML
. -
Remove deprecated
formats
fromActionView::Template::RawFile
. -
Remove deprecated
formats
fromActionView::Template::Text
. -
Remove deprecated
find_file
fromActionView::PathSet
. -
Remove deprecated
rendered_format
fromActionView::LookupContext
. -
Remove deprecated
find_file
fromActionView::ViewPaths
. -
Remove deprecated
format
argumentActionView::Base#initialize
. -
Remove deprecated
ActionView::Template#refresh
. -
Remove deprecated
ActionView::Template#original_encoding
. -
Remove deprecated
ActionView::Template#variants
. -
Remove deprecated
ActionView::Template#formats
. -
Remove deprecated
ActionView::Template#virtual_path=
. -
Remove deprecated
ActionView::Template#updated_at
. -
Make
locals
argument required onActionView::Template#initialize
. -
Remove deprecated
ActionView::Template.finalize_compiled_template_methods
andconfig.action_view.finalize_compiled_template_methods
. -
Remove deprecated support to calling
ActionView::ViewPaths#with_fallback
with a block. -
Remove deprecated support to passing absolute paths to
render template:
. -
Remove deprecated support to passing relative paths to
render file:
. -
Remove deprecated support to template handlers that don’t accept two arguments.
-
Remove pattern argument in
ActionView::Template::PathResolver
. -
Remove support to call private methods from object in some view helpers.
Action Mailer
- Remove deprecated
ActionMailer::Base.receive
in favor of Action Mailbox.
Active Record
-
Remove deprecated methods from
ActiveRecord::ConnectionAdapters::DatabaseLimits
.column_name_length
table_name_length
columns_per_table
indexes_per_table columns_per_multicolumn_index
sql_query_length
joins_per_query
-
Remove deprecated
ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_multi_insert?
. -
Remove deprecated
ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_foreign_keys_in_create?
. -
Remove deprecated
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#supports_ranges?
. -
Remove deprecated
ActiveRecord::Base#update_attributes
andActiveRecord::Base#update_attributes!
. -
Remove deprecated migrations_path argument in
ActiveRecord::ConnectionAdapter::SchemaStatements
. -
Remove deprecated
config.active_record.sqlite3.represent_boolean_as_integer
. -
Remove deprecated methods from
ActiveRecord::DatabaseConfigurations
. -
Remove deprecated
ActiveRecord::Result#to_hash
method. -
Remove deprecated support for using unsafe raw SQL in
ActiveRecord::Relation
methods.
Active Storage
- Remove deprecated support to pass
:combine_options
operations toActiveStorage::Transformers::ImageProcessing
. - Remove deprecated
ActiveStorage::Transformers::MiniMagickTransformer
. - Remove deprecated
config.active_storage.queue
. - Remove deprecated
ActiveStorage::Downloading
.
Active Support
-
Remove deprecated fallback to
I18n.default_local when config.i18n.fallbacks
is empty. -
Remove deprecated
LoggerSilence
constant. -
Remove deprecated
ActiveSupport::LoggerThreadSafeLevel#after_initialize
. -
Remove deprecated
Module#parent_name
,Module#parent
andModule#parents
. -
Remove deprecated file
active_support/core_ext/module/reachable
. -
Remove deprecated file
active_support/core_ext/numeric/inquiry
. -
Remove deprecated file
active_support/core_ext/array/prepend_and_append
. -
Remove deprecated file
active_support/core_ext/hash/compact
. -
Remove deprecated file
active_support/core_ext/hash/transform_values
. -
Remove deprecated file
active_support/core_ext/range/include_range
. -
Remove deprecated
ActiveSupport::Multibyte::Chars#consumes?
andActiveSupport::Multibyte::Chars#normalize
. -
Remove deprecated
ActiveSupport::Multibyte::Unicode.pack_graphemes
,ActiveSupport::Multibyte::Unicode.unpack_graphemes
,ActiveSupport::Multibyte::Unicode.normalize
,ActiveSupport::Multibyte::Unicode.downcase
,ActiveSupport::Multibyte::Unicode.upcase
andActiveSupport::Multibyte::Unicode.swapcase
. -
Remove deprecated
ActiveSupport::Notifications::Instrumenter#end=
.
7. Next steps
If you successfully followed all of these steps, you should now be running Rails 6.1! Do you have any other useful tips or recommendations? Did we miss anything important? Share them with us in the comments section.
If you’re not on Rails 6.1 yet, we can help! Download our free eBook: The Complete Guide to Upgrade Rails .