This Week in Rails

December 11, 2021

Rails 7.0 RC1, faster template rendering, better tests and much more!

Hi! Robin here, with the latest news from the Ruby on Rails world!

Rails 7.0 RC1: New JavaScript Answers, At-Work Encryption, Query Origin Logging, Zeitwerk Exclusively
With tons of new features and improvements like new ways to deal with JavaScript or at-work encryption, this new version of Rails should be released before Christmas! 🎉🎄

It would be great if you could try to install it and report any bug or regression you may find. You can follow these steps to upgrade your applications.

Compile ERB templates with frozen string literal enabled
If your application renders heavy templates, a brand new configuration option is available to enable frozen_string_literal in your views that might give you a performance boost.

Reset instance variables between tests in ActionController::TestCase
To avoid any surprising outcomes that may happen when instance variables' values persist, this patch properly resets variables defined during each test.

Wrap request calls with the Rails executor in ActionController::TestCase
Similarly to the previous patch, this one lessens pitfalls executing controller tests by properly resetting global states at the end of each request. This also improves parity with ActionDispatch::IntegrationTest.

Add authenticate_by method for models with has_secure_password
Active Record models that rely on has_secure_password now have a brand new method which provides a handy shortcut to find and authenticate a record. Moreover, it addresses a potential timing-based security vulnerability using a finder method before authentication. Less code, more security!

Move multi-database configuration to an initializer
Rather than generating settings in the production environment file, a new generator is now available to create an initializer to configure multi-database settings. This eases parity between your different environments.

Use built-in Ruby regex for e-mail validation
Just as a Pro Tip™, the Ruby standard library has a built-in regex to check if an e-mail address is valid or not. Much easier than mentally compiling any home-made regular expression and less error-prone.

Avoid double string split in ActiveSupport::MessageVerifier
It's always nice to see how people can improve performances. This patch brings a tiny boost to the #verified method of the MessageVerifier class by avoiding an extra split on the provided string.

Since last time, 41 people contributed to Rails. There's too much changes to cover them but you can check out all of these here. Until next time!

About This Week in Rails

Your weekly inside scoop of interesting commits, pull requests and more from Rails.