Upgrading Rails

Introduction

When upgrading a Rails application from one version to another, there are built-in tools and community resources that can help.

  1. Rails Upgrade Guide: Each new Rails version comes with an Upgrade Guide that describes the steps required to upgrade an application. It includes a list of breaking changes and provides instructions on how to adapt your application.

  2. RailsDiff: RailsDiff (railsdiff.org) is a tool that shows the differences between two versions of Rails, for each file that is generated in a new Rails application. It can be a good starting point to see what changes are made in the new Rails version.

  3. Deprecation Warnings: Running your test suite with the deprecation warnings turned on can also be a good way to find out what parts of your app are using features that have been deprecated.

  4. RuboCop Rails Upgrade Cop: RuboCop has a Rails Upgrade Cop that detects offences in your code that prevent upgrading to the next Rails version. It can automatically correct some of them, which is somewhat similar to how CodeMods work.

  5. Gemfile Updates: You will also likely need to update some of your gems to versions compatible with the new Rails version.

  6. Automated Tools: There are services like FastRuby.io that provide a gem next_rails which allows you to dual boot your Rails application with two versions of Rails, making the upgrade process easier.

  7. Test Suite: Ultimately, a comprehensive test suite is the most important tool you have when upgrading Rails. It will help you catch regressions and confirm that your app still works as expected with the new Rails version.

In summary, while there isn’t a codemod equivalent for Rails upgrades, there are a combination of tools and resources that can help you navigate the process.