Upgrade Rails from 7.1 to 7.2

Upgrade Rails from 7.1 to 7.2

This article is part of our Upgrade Rails series. To see more of them, click here opens a new window .

This article will cover the most important aspects that you need to know to get your Ruby on Rails opens a new window application from version 7.1 opens a new window to version 7.2 opens a new window .

  1. 1. Preparations
  2. 2. Ruby Version
  3. 3. Gems
  4. 4. Config Files
  5. 5. Rails Guides
  6. 6. Notable New Features
  7. 7. Application Code
  8. 8. Next Steps

1. Preparations

Before beginning with the upgrade process, we have some recommended preparations:

For full details check out our article on How to Prepare Your App for a Rails Upgrade opens a new window .

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 opens a new window is the required minimum version

Check out our Ruby & Rails Compatibility Table opens a new window 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 opens a new window . We also encourage you to use the next-rails opens a new window 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 opens a new window to learn more.

4. Config Files

Rails includes the rails app:update task opens a new window . You can use this task as a guideline as explained thoroughly by this Revisiting rails:update opens a new window blog post.

As an alternative, check out RailsDiff opens a new window , 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 opens a new window 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 opens a new window 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 opens a new window 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 opens a new window

  • 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 opens a new window
7.2 Action Pack
  • Remove deprecated constant ActionDispatch::IllegalStateError.
  • Remove deprecated constant AbstractController::Helpers::MissingHelperError.
  • Remove deprecated comparison between ActionController::Parameters and Hash.
  • Remove deprecated Rails.application.config.action_dispatch.return_only_request_media_type_on_content_type.
  • Remove deprecated speaker, vibrate, and vr permissions policy directives.
  • Remove deprecated support to set Rails.application.config.action_dispatch.show_exceptions to true and false.
  • See full list of changes in the changelog opens a new window
7.3 Action View
7.4 Action Mailer
  • Remove deprecated config.action_mailer.preview_path.
  • Remove deprecated params via :args for assert_enqueued_email_with.
  • See full list of changes in the changelog opens a new window
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 from ActiveRecord::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 and InternalMetadata classes as arguments to ActiveRecord::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 the role 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 to add_foreign_key.
  • Remove deprecated support to pass rewhere to ActiveRecord::Relation#merge.
  • Remove deprecated behavior that would rollback a transaction block when exited using return, break or throw.
  • See full list of changes in the changelog opens a new window
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 opens a new window
7.7 Active Support
  • Remove deprecated ActiveSupport::Notifications::Event#children and ActiveSupport::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 from Array, Date, DateTime and Time.
  • 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 and ActiveSupport::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 to MemCacheStore.
  • See full list of changes in the changelog opens a new window
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 in retry_on.
  • See full list of changes in the changelog opens a new window

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. opens a new window

Download our free eBook: The Complete Guide to Upgrade Rails opens a new window .

Get the book