This Week in Rails

November 18, 2022

The Rails Foundation, Stimulus Outlets API, bug fixes and lots of improvements!

Boa noite! This is Emmanuel, bearer of good tidings.

Introducing: The Rails Foundation
In case you missed it, with eight founding members, Rails has started The Rails Foundation! Together, the founding members have contributed a total sum of $1,000,000 that will aid the foundation's mission to improve the documentation, education, marketing, and events in our ecosystem. More here.

Raise on assignment to readonly attributes
Attributes that are marked as attr_readonly would previously fail silently, meaning data won't be written to the database when you tried to assign new values—with this PR, read-only attributes will raise an ActiveRecord::ReadonlyAttributeError when an attempt is made to write to that read-only attribute.

Allow unscoping of preload and eager_load associations
This PR adds the ability to unscope preloaded and eager loaded associations, adding to the list of valid "unscoping" values like where, select among others.

Add filtering of encrypted attributes in #inspect
Previously, encrypted attributes could be added to an application's filter_parameters which would filter the attribute values from logs. This commit adds an additional config to enable adding encrypted attributes to records' filter_attributes, which allows them to be filtered when models are inspected (such as in the console).

Initialize encrypted attributes when using #first_or_create or #first_or_initialize
This fixes a bug where one would expect that encrypted values are initialized with the values provided but instead, the encrypted values were nil.

Stimulus gets an Outlets API
Around Hotwire, this PR received a warm welcome. I reached out to the author, Marco Roth,  who whipped out a documentation that perfectly summarises the Outlet API:

The Outlets API lets you reference Stimulus Controller instances and their controller element from within another Stimulus Controller by using CSS selectors. The use of Outlets helps with cross-controller communication and coordination as an alternative to dispatching custom events on controller elements.

Ruby on Rails saw 22 generous contributors in the last 7 days.

Talk to you next week.