ruby-on-railsrubyruby-on-rails-4

looking for recommended upgrade path for app (ruby 2.3.8 , rails 4.2.11) to the latest stable versions of ruby and rails


as the title states, I'm looking for a recommended path for app (ruby 2.3.8 , rails 4.2.11) to the latest stable versions of ruby and rails, that is the safest, most stable option for a very, very large codebase.

e.g.

any recommendations / guidance would be greatly appreciated.


Solution

  • The first step is to make sure that your application has enough tests to give you confidence during upgrading the application.

    Then you can start the actual upgrade process. There are different ways to do this. I usually suggest updating in smaller steps, instead of huge all in once upgrades, because that makes it much easier to fix issues along the way because you know exactly with Ruby or Ruby on Rails version introduced the issue.

    Additionally, each Ruby on Rails version has a range of Ruby versions they are compatible with, and you have to update them in matching combinations.

    Some people propose that you should upgrade to the lowest minor and patch version first and then to the latest minor, for example, like 5.0.7.2 -> 5.1.0 -> 5.1.7. But in my experience, it is fine to update directly to the latest version of the next minor version, like 5.0.7.2 -> 5.1.7.

    I recommend following this table with Ruby and Ruby on Rails compabilities. This leads to the following upgrade path:

    ruby 2.3.8   rails 4.2.11    your current versions
                       |
    ruby 2.3.8   rails 4.2.11.3
                       |
    ruby 2.3.8   rails 5.0.7.2
         |
    ruby 2.4.10  rails 5.0.7.2
                       |
    ruby 2.4.10  rails 5.1.7
         |
    ruby 2.5.9   rails 5.1.7
                       |
    ruby 2.5.9   rails 5.2.8.1
         |
    ruby 2.6.10  rails 5.2.8.1
                       |
    ruby 2.6.10  rails 6.0.6.1
                       |
    ruby 2.6.10  rails 6.1.7.10
         |
    ruby 2.7.8   rails 6.1.7.10    
         |
    ruby 3.0.7   rails 6.1.7.10  
                       |
    ruby 3.0.7   rails 7.0.8.8    
         |
    ruby 3.1.6   rails 7.0.8.6  
         |
    ruby 3.2.6   rails 7.0.8.6
                       |
    ruby 3.2.6   rails 7.1.5     minimum combination to still get security fixes
         |
    ruby 3.3.6   rails 7.1.5
                       |
    ruby 3.3.6   rails 7.2.2     minimum combination to still get bug fixes
                       |
    ruby 3.3.6   rails 8.0.0
    

    Note that at the time of the last update of this answer (Novermber 2024) Ruby 3.1 and Ruby on Rails 7.1.x still get security fixes. Therefore, I would suggest that to be the lowest version combination to run on production. Bug fixes are only available for Ruby 3.2 and Ruby on Rails 7.2.x and above.

    During each step, consult Upgrading Ruby on Rails in the official Rails Guides about what changed in that specific version. After each step, make sure to fix all deprecation warnings that might occur.

    Please keep in mind reviewing all your other gems too. I would consider it a good practice to update all gems to the latest versions that are compatible with your current Ruby and Ruby on Rails combination after each step and before making the next upgrade step.