Upgrade Rails from 7.1 to 7.2
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 7.1 to version 7.2 .
- 1. Preparations
- 2. Ruby Version
- 3. Gems
- 4. Config Files
- 5. Rails Guides
- 6. Notable New Features
- 7. Application Code
- 8. Next Steps
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. We do have an article for strategies on upgrading with low test coverage as well.
- Have a staging environment that is as similar as possible to production, so that proper QA can be completed.
- 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 refer to our Solving Dual Booting Issues when Changes aren’t Backwards Compatible article.
For full details check out our article on How to Prepare Your App for a Rails Upgrade .
2. Ruby Version
Previously, Rails has only dropped compatability with older Ruby versions with the release of a new major version. With Rails 7.2 comes a big change that will now see EOL Ruby versions dropped with the release of minor versions as well. This is to avoid the complications involved in maintaining compatibilities with unsupported versions of Ruby.
For the Rails 7.2 release, Ruby 3.1 is the required minimum version
Check out our Ruby & Rails Compatibility Table to see all the required Ruby versions across all Rails versions.
3. Gems
Make sure you check the GitHub page of the gems currently installed in your application for more information about compatibility with Rails 7.2. If you are the maintainer of the gem, you’ll need to make sure it supports Rails 7.2.
A great tool to checkout gems compatibility is RailsBump .
We also encourage you to use the next-rails
gem to run bundle_report outdated
for more information on gems that will require an update. Check out our article on The Next Rails Gem to learn more.
4. Config Files
Rails includes the rails app:update
task .
You can use this task as a guideline as explained thoroughly by this Revisiting rails:update blog post.
As an alternative, check out RailsDiff , which provides an overview of the changes in a basic Rails app between 7.1.x and 7.2.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. Notable New Features
- Development Container Configurations: Rails 7.2 adds the ability to generate a development container configuration for new and existing Rails applications that will include a
.devcontainer
directory with the following files:- Dockerfile,
- docker-compose.yml
- devcontainer.json
-
Browser Version Guarding: Rails will now allow specifications regarding what browser versions can be granted accessibility as well as limiting browser versions to actions with the allow_browser method.
-
Progressive Web Application Files (PWA) will be generated by default, served from
app/views/pwa
and can be dynamically served from ERB files. -
Omakase RubuCop rules: Rails applications will by default be configured with a set of rules defined by rubocop-rails-omakase
-
GitHub CI workflow: New applications will come equipped and ready with Github CI workflows, making it easier to begin with automated scanning, linting, and testing.
-
Brakeman: Along with the Github CI workflows, all new applications will also include Brakeman by default to help continuously scan for possible security vulnerabilities.
- YJIT is now enabled by default for new applications running on Ruby 3.3+
7. Application Code
If you have ignored deprecation warnings on past version jumps, and haven’t stayed 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. The following is a list of the removals in Rails 7.2.
7.1 Railties
- Remove deprecated
Rails::Generators::Testing::Behaviour
. - Remove deprecated
Rails.application.secrets
. - Remove deprecated
Rails.config.enable_dependency_loading
. - Remove deprecated
find_cmd_and_exec
console helper. - Remove support for oracle, sqlserver, and JRuby specific database adapters from the new and
db:system:change
rails commands. - Remove
config.public_file_server.enabled
option from the generators. - See full list of changes in the changelog
7.2 Action Pack
- Remove deprecated constant
ActionDispatch::IllegalStateError
. - Remove deprecated constant
AbstractController::Helpers::MissingHelperError
. - Remove deprecated comparison between
ActionController::Parameters
andHash
. - Remove deprecated
Rails.application.config.action_dispatch.return_only_request_media_type_on_content_type
. - Remove deprecated
speaker
,vibrate
, andvr
permissions policy directives. - Remove deprecated support to set
Rails.application.config.action_dispatch.show_exceptions
totrue
andfalse
. - See full list of changes in the changelog
7.3 Action View
- Remove deprecated
@rails/ujs
in favor of Turbo. - See full list of changes in the changelog
7.4 Action Mailer
- Remove deprecated
config.action_mailer.preview_path
. - Remove deprecated params via
:args
forassert_enqueued_email_with
. - See full list of changes in the changelog
7.5 Active Record
- Remove deprecated
Rails.application.config.active_record.suppress_multiple_database_warning
. - Remove deprecated support to call
alias_attribute
with non-existent attribute names. - Remove deprecated
name
argument fromActiveRecord::Base.remove_connection
. - Remove deprecated
ActiveRecord::Base.clear_active_connections!
. - Remove deprecated
ActiveRecord::Base.clear_reloadable_connections!
. - Remove deprecated
ActiveRecord::Base.clear_all_connections!
. - Remove deprecated
ActiveRecord::Base.flush_idle_connections!
. - Remove deprecated
ActiveRecord::ActiveJobRequiredError
. - Remove deprecated support to define
explain
in the connection adapter with 2 arguments. - Remove deprecated
ActiveRecord::LogSubscriber.runtime method
. - Remove deprecated
ActiveRecord::LogSubscriber.runtime= method
. - Remove deprecated
ActiveRecord::LogSubscriber.reset_runtime method
. - Remove deprecated
ActiveRecord::Migration.check_pending method
. - Remove deprecated support to passing
SchemaMigration
andInternalMetadata
classes as arguments toActiveRecord::MigrationContext
. - Remove deprecated behavior to support referring to a singular association by its plural name.
- Remove deprecated
TestFixtures.fixture_path
. - Remove deprecated support to
ActiveRecord::Base#read_attribute(:id)
to return the custom primary key value. - Remove deprecated support to passing coder and class as second argument to
serialize
. - Remove deprecated
#all_foreign_keys_valid?
from database adapters. - Remove deprecated
ActiveRecord::ConnectionAdapters::SchemaCache.load_from
. - Remove deprecated
ActiveRecord::ConnectionAdapters::SchemaCache#data_sources
. - Remove deprecated
#all_connection_pools
. - Remove deprecated support to apply
#connection_pool_list
,#active_connections?
,#clear_active_connections!
,#clear_reloadable_connections!
,#clear_all_connections!
and#flush_idle_connections!
to the connections pools for the current role when therole
argument isn’t provided. - Remove deprecated
ActiveRecord::ConnectionAdapters::ConnectionPool#connection_klass
. - Remove deprecated
#quote_bound_value
. - Remove deprecated support to quote
ActiveSupport::Duration
. - Remove deprecated support to pass
deferrable: true
toadd_foreign_key
. - Remove deprecated support to pass
rewhere
toActiveRecord::Relation#merge
. - Remove deprecated behavior that would rollback a transaction block when exited using
return
,break
orthrow
. - See full list of changes in the changelog
7.6 Active Storage
- Remove deprecated
config.active_storage.replace_on_assign_to_many
. - Remove deprecated
config.active_storage.silence_invalid_content_types_warning
. - See full list of changes in the changelog
7.7 Active Support
- Remove deprecated
ActiveSupport::Notifications::Event#children
andActiveSupport::Notifications::Event#parent_of?
. - Remove deprecated support to call the following methods without passing a deprecator:
deprecate
deprecate_constant
ActiveSupport::Deprecation::DeprecatedObjectProxy.new
ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new
ActiveSupport::Deprecation::DeprecatedConstantProxy.new
assert_deprecated
assert_not_deprecated
collect_deprecations
- Remove deprecated
ActiveSupport::Deprecation
delegation to instance. - Remove deprecated
SafeBuffer#clone_empty
. - Remove deprecated
#to_default_s
fromArray
,Date
,DateTime
andTime
. - Remove deprecated
:pool_size
and:pool_timeout
options for the cache storage. - Remove deprecated support for
config.active_support.cache_format_version = 6.1
. - Remove deprecated constants
ActiveSupport::LogSubscriber::CLEAR
andActiveSupport::LogSubscriber::BOLD
. - Remove deprecated support to bolding log text with positional boolean in
ActiveSupport::LogSubscriber#color
. - Remove deprecated
config.active_support.disable_to_s_conversion
. - Remove deprecated
config.active_support.remove_deprecated_time_with_zone_name
. - Remove deprecated
config.active_support.use_rfc4122_namespaced_uuids
. - Remove deprecated support to passing
Dalli::Client
instances toMemCacheStore
. - See full list of changes in the changelog
7.8 Active Job
- Remove deprecated primitive serializer for
BigDecimal
arguments. - Remove deprecated support to set numeric values to
scheduled_at
attribute. - Remove deprecated
:exponentially_longer
value for the:wait
inretry_on
. - See full list of changes in the changelog
8. Next Steps
If you successfully followed all of these steps, you should now be running Rails 7.2!
If you find yourself in need of assistance or your team doesn’t have the time to tackle these challenges, you can always contact us. Our experts are here to help you navigate the upgrade process and ensure your Rails application continues to thrive.
Download our free eBook: The Complete Guide to Upgrade Rails .