What's New in Ruby on Rails 5.1?
Written by Chris • 31 March 2017
Let’s take a look at some of the changes that Rails 5.1 brings in detail:
System tests allow you to automate the testing of your application across all layers – view, controller, models, mailers, etc., and are an essential tool in continuously deploying production-ready code. Capybara has long been the standard for performing automated, full-stack system tests on your apps. Getting it setup, though, has required quite a lot of boilerplate and configuration tweaks.
With Rails 5.1, Capybara comes baked-in with Rails, and is setup to use Chrome by default. Database cleanup strategies are also no longer a concern, as transactional tests now rollback their database changes by default.
Encrypted secrets will be a huge plus for many people who use Rails’
secrets.rb file to store things like API keys, third-party app credentials, etc. Previously, it was all-too-easy to accidentally commit the file to the repository, and expose those secrets.
Rails 5.1 brings encryption to the
secrets.rb file, meaning it can be safely committed to the code repository and decrypted at runtime through a single environment variable containing the master key (
Unified Form Tags
Rails 5.1 includes a small simplification to the forms API by merging
form_tag into a single
As you’d expect, Rails 5.1 comes with a lot of minor tweaks and improvements, as well as bug-fixes. You can see the full list of changes on the official Rails blog post.
Is Your App Ready for Rails 5.1?
Is your app ready for Rails 5.1? If you’ve already upgraded your app to 5.0, or a later version of 4.x, then the path to upgrade should be fairly simple. If you use secrets.rb to store your app’s secret data, then the encrypting coming in 5.1 will be a huge benefit.
If your app is running an older release of Rails, then there will be some more development work required to bring your app up-to-date. However, with the ongoing improvements and efficiencies that Rails receives, this is always a worthwhile investment.