This Week in Rails

August 25, 2023

This Week in Rails - August 25

Hi, Wojtek here. Let’s explore last 2 week’s changes in the Rails codebase.

Rails Versions, have been released
Just after the previous security releases, but with fixed file permissions.

MRSK renamed to Kamal
Due to a trademark claim, the project was renamed to Kamal.

Add after_discard method to Active Job
It lets job authors to define a block which will be run when a job is about to be discarded.

Ensure response.parsed_body support for pattern matching
Both Nokogiri and Minitest supports Ruby’s Pattern matching. By parsing the JSON contents of response.parsed_body with ActiveSupport::HashWithIndifferentAccess, it’s now pattern-matching compatible and can be used with Minitest’s new assert_pattern method.

Add support for Playwright as a driver for system tests
Playwright is getting popularity as a new browser automation tool. There is a community-maintained Ruby client and Capybara driver as well.

Generate config.autoload_lib for new Rails 7.1 apps
New 7.1 applications will autoload from lib directory out of the box. The new line in config/application.rb contains: config.autoload_lib(ignore: %w(assets tasks)).

Allow redefining to_param delimiter using param_delimiter
Adds ActiveModel::Conversion.param_delimiter to configure delimiter being used in to_param method.

Deprecate read_attribute(:id) returning the primary key
Starting in Rails 7.2, read_attribute(:id) will return the value of the id column, regardless of the model’s primary key. To retrieve the value of the primary key, one can use #id instead. read_attribute(:id) for composite primary key models will now return the value of the id column.

Use alias_attribute to provide id_value alias for id attribute
As the follow up to the above, added ActiveRecord::Base#id_value alias to access the raw value of a record’s id column. This alias is only provided for models that declare an :id column.

Add an option to start rails console in sandbox mode by default
sandbox_by_default option is added to start rails console in sandbox mode by default. With this option turned on, --no-sandbox must be specified to start rails in non-sandbox mode. Note that this option is ignored when rails environment is development or test.

Fix host display when X_FORWARDED_HOST authorized
Fix HostAuthorization potentially displaying the value of the X_FORWARDED_HOST header when the HTTP_HOST header is being blocked.

You can view the whole list of changes here. We had 35 contributors to the Rails codebase this past week!

Until next time!

About This Week in Rails

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