I have a legacy application of ruby on rails 4.2 and ruby version 2.6. As ruby 2.6 upgrade has reached its end of life, I need to upgrade to ruby 3.1.
when I checked rails | RubyGems.org | your community gem host its says only the lower limit. ie ruby version greater 1.9.3 is enough. It did not mention if its supported officially with ruby 3.
but when I tried to rails 4.2 application on ruby 3. It failed . It failed even for ruby 2.7.
So How can i know should I update my rails version or not?
As ruby 2.6 upgrade has reached its end of life, I need to upgrade to ruby 3.1
Note that Rails 4.2 has reached end of life too.
It did not mention if its supported officially with ruby 3.
For older Rails versions, you can look into .travis.yml file to find out what Ruby versions it was tested with.
Rails 4.2 was released on 2014-12-20, Ruby 3.0 on 2020-12-25. So when Rails 4.2 was released, nobody was aware of Ruby 3.0 - developers could only test against Ruby versions at that time.
Of course somebody could take the effort and test compatibility of newer Ruby versions against old Rails versions, but I guess it’s not that interesting.
My personal advice would be: If you have to maintain an old Rails app, stick to the Ruby version you know it’s running OK with. If you want to upgrade because of security concerns, you should upgrade the Ruby version plus the Rails version plus all the other versions from the Gemfile.
Rails 4.2 was released long before Ruby 2.7 and Ruby 3.0. These versions introduced breaking changes and deprecations. For ex, Ruby 2.7 and 3.0 introduced changes to how keyword arguments are handled, which Rails 4.2 doesn’t account for. Also, many of the gems you’re using might not support Ruby 2.7 or 3.0 when paired with Rails 4.2.
You can also try using RailsUp. This is a free gems compatibility checker tool. You can analyze your app’s gemfile and identify outdated or incompatible gems. You can also get the complexity score and an estimate of the time required for the upgrade process.
It’s pretty much a “Rails +” kind of option for either upgrading existing apps or creating new ones. (Or just quickly spinning up an admin panel to be used for development / testing.)