Friday, May 31, 2024

Propshaft default for Rails 8, Guides updates, transaction.active_record events, and more!

Posted by zzak

Hi, it’s zzak. Let’s explore this week’s changes in the Rails codebase.

Rails World 2024 speaker lineup announced!
As well as another small run of tickets going live on June 4 at 2pm ET!

The Rails Foundation documentation team has also submitted two Rails guides for community review. If you have feedback, please submit it here: Action View Form Helpers Guide and the Active Record Migrations Guide.

Change asset pipeline default to Propshaft in Rails 8
Sprockets has served us well, but it’s time to hand over the torch to Propshaft in Rails 8.

Add a Rails Guide called “Tuning Performance for Deployment”
This guide explains major concurrency and performance principles for Puma and CRuby.

Pass the transaction object to “transaction.active_record” subscribers
The Active Support Instrumentation event for transaction.active_record now comes with the transaction in the payload, way you can refer to transactions if you need to trace database activity.

Include the current transaction in “sql.active_record” event payloads
After the previous change, we also include the current transaction in sql.active_record event payloads. This allows tracing database activity including the ability to group queries by transaction, thanks to the recently added ActiveRecord::Transaction#uuid.

Define Digest::UUID.nil_uuid
As defined in RFC 4122 the so-called nil UUID is now added to Digest::UUID.

Update public directory during app:update command
This PR fixes a bug when upgrading Rails versions where the app:update command did not generate new files in /public. For example, upgrading from Rails 7.1 to 7.2 does not create the new 406-unsupported-browser.html file.

Update permissions policy list with display-capture and keyboard-map
Since display-capture (Chrome 94) and keyboard-map (Chrome 97) are now standardized policy controlled features.

Improve compatibility for “ActiveSupport::BroadcastLogger”
This PR changes the return value for all logging methods to return true, similar to the Logger class in Ruby.

Add CSP mapping for “wasm-unsafe-eval”
The 'wasm-unsafe-eval' keyword for the Content Security Policy allows the loading and execution of WebAssembly modules without the need to allow unsafe JavaScript execution via 'unsafe-eval'.

Improve ActionCable’s TestCookieJar interface
This PR makes using ActionCable::Connection::TestCookieJar similar to ActionDispatch::Cookies::CookieJar with regards to setting the cookie value.

Raise a descriptive error when a Store column is misconfigured
If a developer has neglected to use a structured column type (hstore or json) or to declare a serializer with ActiveRecord.store, then a ConfigurationError will now be raised with a nice error message instead of a NoMethodError with no detail.

Make pretty_print behave more similar to inspect
This Pull Request makes the behavior of pretty_print on Active Record objects match that of inspect, instead of using the “raw” attribute it uses attribute_for_inspect.

Fix non-partial inserts for models with composite identity primary keys
When doing non-partial inserts, we should ignore not only unchanged columns with a default function, but also which are autoincremented in the database (and so don’t have a default function).

Catch StandardError during Base64 decoding in message encryptor
RubyGems.org got recently facing 500 HTTP responses since user mangled cookies (app uses cookie store) and provided custom value which (thanks to series of edge-cases) ended up triggering NoMethodError: undefined method unpack1' for nil raised down from Base64 class.

Index Result rows rather than to convert them into hashes
This optimization improves the performance of Result#each by avoiding to convert each row into a hash.

Add “ActiveRecord::Relation#readonly?”
A new method added to the relation object lets developers check if it was marked readonly.

Fix AllowBrowser versions
This PR updates the :modern browser settings when using the allow_browser helper to support Chrome v120+ and Opera v106+, which includes support for CSS nesting.

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

Until next time!

Subscribe to get these updates mailed to you.