Filter

Sign up for our newsletter

Recieve a selection of our favorite articles the first Friday of every month!

Article  |  Development

Should we upgrade to Rails 5?

Reading time: ~ 4 minutes

Should we upgrade to Rails 5?

Ruby on Rails version 5.1.1 is officially out and in use. While the latest release on May 12th was a minor one, version 5.0 brought some major updates to Rails – including new JavaScript abilities with Yarn and webpack, system tests with Capybara, encrypted secrets, and more. (Click here to read the full Rails 5 release notes.)

You may have discussed upgrading your Rails app with your internal team. Using this new version is a no-brainer for a new project, but should your team take the time to upgrade your existing Ruby on Rails app?

Even aside from its new features, v5 brings numerous benefits. In particular, the Rails core team has been paying a lot of attention to performance, efficiency, and memory usage for this new release.

With the newest version of Rails, your team will be better positioned to squeeze more value out of your organization’s server resources.

Still running on an older version of Rails?

If you're still running Rails v3.x, now is definitely the time to start your upgrade journey. Now that v5 is out in the wild, 3.x is no longer receiving further updates.

Let me repeat that. Ruby on Rails 3.x is no longer actively supported; not even for severe security issues.

You don't want to wait until a major security vulnerability is discovered to start the upgrade process to a more recent Rails version. This would leave your business and customers vulnerable for however long as it takes your team to execute that upgrade.

If you're on a version of Rails that's older than 4.2.x, bear in mind that moving to v5 will be a multi-stage upgrade. You should only ever upgrade one minor release at a time (e.g., 4.1 to 4.2 to 5.0 instead of 4.1 directly to 5.0). Otherwise, you can't avail yourself of the deprecation warnings and instead will run into hard-to-debug issues because that behavior has been removed entirely.

If you're several versions behind, don't despair and think you're in for months of work! We recently upgraded a medium-sized app from Rails 3.2 to 4.2 (a three-stage upgrade), and while we encountered several thorny issues (mostly due to external gem dependencies), it only took about thirty hours of developer time all told.

While an upgrade seldom goes entirely without hiccups, the Rails team does an excellent job of making the process as developer-friendly as possible. Along with the release of Rails 5, the Rails team had put together a guide for upgrading from v4.2 to v5, detailing the breaking changes and recently deprecated behavior.

For example, if you're running v4.2.x, your app will already be giving you warnings about the deprecated behavior that will be removed in v5.

Quick tip: Developers might want to set ActiveSupport::Deprecation.debug = true in their development and test environments to turn easy-to-miss deprecation warnings into unignorable hard errors that halt execution.

If you don't get any deprecation warnings from your v4.2 app, you're likely to have a fairly smooth upgrade to v5!

Upgrading and Rails Gems

One of the most common reasons why Rails developers are held back from staying up-to-date is due to gem dependencies.

If your Ruby on Rails application depends on several external Ruby gems, you may not be able to upgrade. In an ideal world, gem maintainers would have been testing their project on the pre-release versions of v5 so that the gem is fully compatible by the time v5.0 is released, but in reality some gems that are in less active development will take some time (and testing) to release a v5-compatible gem.

If your team has the resources to contribute, most gem maintainers would be happy to take a pull request that brings Rails 5 support. In our open source community, it’s contributions like this that keep Rails ticking along after all these years. You can also try checking the home repositories of some of your gems that don’t yet have Rails 5 support. There may be a branch on their GitHub that includes support but has not been fully tested and merged just yet.

Not sure if your gems are ready for an upgrade? Check your Rails gem files with Ready4Rails which will tell you which gems are ready to update to Rails 4.x or 5.x. This is another great place to contribute your knowledge – a huge number of Rails gems on this site are marked unknown. If you use one and find out if it’s ready to update or not, leave a comment with your experience.

In Conclusion

Generally speaking, unless you have a compelling reason to stay on an older version of Rails, you should upgrade when you have resources available. Keeping fairly up to date allows you to amortize your upgrade costs by dealing with more frequent small upgrades instead of rare colossal upgrades.

But in the tumultuous world of software development, upgrades aren’t always the highest priority. If you’re reading this and think – I wish I could upgrade, but – we’d love to hear from you! Whether you’re waiting on a key gem to get up to speed, or you can’t convince your boss that upgrading is worth the development hours, let us know your thoughts. We’re doing research on the world of Rails updates and want to hear your experiences.

Want to do more research on upgrading your Rails app? Here are some helpful resources.

Editors Note: This post was originally published on April 4, 2016. It has been revamped and updated for accuracy and comprehensiveness and to include details about Ruby on Rails version 5.x.


Considering an upgrade to Rails 5? We can help.

Whether you're looking for an audit to spot potential challenges, a guiding hand through the process, or just want to get this upgrade off your to-do list, we have the experience and knowledge to help you out. Click below to find out more and schedule a call to discuss your Rails upgrade.

Talk to us about your Rails Upgrade
comments powered by Disqus

Have a project that needs help?

New Call-to-action