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 notestasks. -
Remove deprecated
connectionoption in therails dbconsolecommand. -
Remove deprecated
SOURCE_ANNOTATION_DIRECTORIESenvironment variable support fromrails notes. -
Remove deprecated
serverargument from the rails server command. -
Remove deprecated support for using the
HOSTenvironment variable to specify the server IP. -
Remove deprecated
rake dev:cachetasks. -
Remove deprecated
rake routestasks. -
Remove deprecated
rake initializerstasks.
Action Pack
-
Remove deprecated
ActionDispatch::Http::ParameterFilter. -
Remove deprecated
force_sslat the controller level.
Action View
-
Remove deprecated
escape_whitelistfromActionView::Template::Handlers::ERB. -
Remove deprecated
find_all_anywherefromActionView::Resolver. -
Remove deprecated
formatsfromActionView::Template::HTML. -
Remove deprecated
formatsfromActionView::Template::RawFile. -
Remove deprecated
formatsfromActionView::Template::Text. -
Remove deprecated
find_filefromActionView::PathSet. -
Remove deprecated
rendered_formatfromActionView::LookupContext. -
Remove deprecated
find_filefromActionView::ViewPaths. -
Remove deprecated
formatargumentActionView::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
localsargument required onActionView::Template#initialize. -
Remove deprecated
ActionView::Template.finalize_compiled_template_methodsandconfig.action_view.finalize_compiled_template_methods. -
Remove deprecated support to calling
ActionView::ViewPaths#with_fallbackwith 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.receivein favor of Action Mailbox.
Active Record
-
Remove deprecated methods from
ActiveRecord::ConnectionAdapters::DatabaseLimits.column_name_lengthtable_name_lengthcolumns_per_tableindexes_per_table columns_per_multicolumn_indexsql_query_lengthjoins_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_attributesandActiveRecord::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_hashmethod. -
Remove deprecated support for using unsafe raw SQL in
ActiveRecord::Relationmethods.
Active Storage
- Remove deprecated support to pass
:combine_optionsoperations 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.fallbacksis empty. -
Remove deprecated
LoggerSilenceconstant. -
Remove deprecated
ActiveSupport::LoggerThreadSafeLevel#after_initialize. -
Remove deprecated
Module#parent_name,Module#parentandModule#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.upcaseandActiveSupport::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 .