Recently Ruby on Rails 5.1 has been introduced. Let’s have a look what new features it has to offer to all Rails fans.

On April 27 Rails Conf, which is the major event in Ruby on Rails world, took place in Phoenix, Arizona. It is 12th time Rails professionals from all over the world get together, which made it a perfect place to introduce Ruby on Rails 5.1.

After more than 4,000 commits it is finally ready to add some spice to work of Ruby developers from every corner in the world. Let’s check out what new version has brought about.

1. Javascript

Javascript has significantly improved throughout the last couple of years, taking into account introduction of ES6 as well as package and installation tools. No wonder that Rails also had to keep moving in order to provide better services.

The new version of Ruby on Rails can boast of the following features:

  1. Management of JavaScript dependencies from NPM via Yarn
    Now you will be able to use Yarn as a Bundler for Javascript. To do that simply use the binstub bin/yarn to add dependencies.
  2. Optional compilation of JavaScript with webpack.
    Webpack seems to the on Olympus of module bundlers and compilers. In the new Rails version you will be able to take advantage of the new Webpacker gem, which would configure automatically on new projects. It can even be used for Javascript (managed by Yarn by default).
  3. Dropping jQuery as a default dependency
    Though previously using jQuery for such things as data-remote or data-confirm was a must, it is not the case anymore. You can keep using it if you want, but it is optional now.

2. System Tests

Though system tests are often neglected, they still are extremely important for the success of the project. For a pretty long time the best solution for system tests on Ruby was using Capybara.

In the new version of Ruby on Rails a nice wrapping of Capybara has been introduced, which is preconfigured for Chrome and even sends failure screenshots as part of Action Dispatch. There is some room for improvement though but is already a great step forward.

3. Encryption

Rails 5.1 also provides better ways of encryption. Now you can setup new encrypted secrets file with bin/rails secrets:setup, which would lead to generation of a master key to store outside the repository.

Decryption can be performed either through an injected key file or through RAILS_MASTER_KEY in the ENV.

4. Parameterized Mailers

Previously arguments used for Action Mailer were not available on filters that run before actions. With Parameterized Mailers introduced, this problem will be solved. Now mailers can be called with parameters (similar to controllers), which makes them available before the action is invoked. And don’t forget about total backward compatibility.

5. Direct and resolved routes

Until recently declaring programmatic routes that contain logic determining the final destination was a little bit of a pain. Rails 5.1 introduces directed routes, which should solve the issue.

At the same time, resolved routes allow reprogramming the polymorphic look-up for models with compatible methods. With their help you can turn link_to @comment into a final route like message_path(@comment.parent, anchor: “comment_#{}”).


As you see, Rails 5.1 has a lot to offer. Please find the whole list of features here. Which one did you like best? Share with us in the comments!


How useful was this post?

Click on a star to rate it!

Average rating 4.8 / 5. Vote count: 8

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?


Daria Stolyar is a Marketing Manager at Rubyroid Labs. You can follow her at Linkedin.

Write A Comment slot gacor game slot online Slot88 slot deposit pulsa tanpa potongan