Ruby on Rails Q & A


How to upgrade to a newer Rails version?

Upgrading to a newer Rails version is an essential task to ensure that your application remains secure, performant, and can benefit from the latest features and improvements. Here’s a step-by-step guide on how to upgrade to a newer Rails version:


  1. Check Dependencies: Before starting the upgrade, ensure that all your gem dependencies are compatible with the Rails version you intend to upgrade to. Read their documentation or check their GitHub repositories for compatibility notes.


  1. Backup: Make a backup of your current application or ensure that your version control system (like Git) is up-to-date. This allows you to revert changes if things go awry.


  1. Update the Gemfile: Change the Rails version in your `Gemfile` to the new version you want. For instance, `gem ‘rails’, ‘~> 6.1.0’`.


  1. Run Bundle Update: In your terminal, run `bundle update rails` to update Rails and its dependencies. If you face any dependency issues, you might also need to update other gems.


  1. Use the Upgrade Guide: Rails provides an official upgrade guide for every major and minor release. This guide offers specific instructions and notes on what has changed, what’s deprecated, and what you need to change in your application.


  1. Run the Update Task: For some versions, Rails provides an update task `rails app:update` that helps in replacing configurations and initializers. Review the changes and migrate your custom configurations if necessary.


  1. Update Deprecated Features: The newer Rails version might deprecate some methods or configurations. You’ll need to address these in your application. The deprecation warnings, usually displayed in your logs, can guide you through this.


  1. Test Your Application: After making the necessary changes, run your test suite to ensure everything works as expected. If you don’t have a comprehensive test suite, consider manual testing or adding more tests.


  1. Check External Services: If your Rails application interacts with external services or APIs, ensure they still work correctly with the upgraded Rails version.


  1. Deploy to Staging: Before deploying the upgraded application to production, test it in a staging environment, replicating the production setup.


Upgrading Rails requires careful planning, thorough testing, and a systematic approach. By following the official documentation and addressing deprecated features, you can ensure a smoother transition to the newer Rails version.

Previously at
Flag Argentina
time icon
Senior Software Engineer with a focus on remote work. Proficient in Ruby on Rails. Expertise spans y6ears in Ruby on Rails development, contributing to B2C financial solutions and data engineering.