What's New in Ruby on Rails 5.1?

Rails 5.1, which is currently at release-candidate (RC) stage – continues to keep pace with these latest changes, bringing with it new features include encrypted secrets, javascript dependency improvements, and full-stack testing with Capybara baked in.

Let’s take a look at some of the changes that Rails 5.1 brings in detail:

Javascript Improvements

There’s no doubt that Javascript is becoming more and more pervasive across all platforms, especially with the advent of ECMAScript 6, Typescript, etc.

With Rails 5.1, Javascript dependencies can now be managed through YARN, a Bundler-esque package manager for NPM libraries. Any dependencies managed through YARN are made available to Rails’ asset pipeline.

Rails 5.1 also allows you to compile your Javascript files using Webpack (rather than Sprockets), and slims your apps by removing jQuery as a default dependency and relying on vanilla Javascript.

System Tests

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

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 (ENV['RAILS_MASTER_KEY']).

Unified Form Tags

Rails 5.1 includes a small simplification to the forms API by merging form_for and form_tag into a single form_with tag.

Minor Changes

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.

Need help upgrading, or just want to know how it will affect your Rails app? Get in touch with us today for a free consultation, or take a look at our Rails Upgrade services to see how we can help.

Previous
Previous

3 Ways to Keep Your Ruby on Rails Apps Healthy

Next
Next

Rails on Docker: How to Run Your Rails App on Docker Swarm