This Week in Rails

November 26, 2021

Composable blobs, improved upsert and much more!

Hey, Wojtek here with recent additions to Rails. All of them today for FREE, for you.
Thank you all the contributors for making Rails. Those from one-time to day by day committers.

Add compose method to Active Storage Blob
Concatenating multiple blobs is now possible.

Support custom metadata on Active Storage
Setting custom metadata on blobs are now persisted to remote storage.

Allow to configure the list of columns to update in upsert_all
Before, you could only customize the update SQL sentence via :on_duplicate. There is now a new option :update_only that lets you provide a list of columns to update in case of conflict.

Expose role/shard on pool/connection
It can be useful to know what the role and shard of the connection or pool is. Previously there was no way to find the role or shard other than asking connected_to?.

Allow a fallback value to be returned from Rails.error.handle
The passed fallback will be returned in case the code inside the handle block raises an error.
Improved later to make a fallback option to be a callable.

Add existence method to Pathname
Shorthand for code like:
Rails.root.join('file').exist? && Rails.root.join('file').read
This header has been deprecated and the XSS auditor it triggered has been removed from all major modern browsers (in favour of Content Security Policy) that implemented this header to begin with.

Deprecate PerThreadRegistry
This module has been soft deprecated for a long time, but since it was used internally it wasn't throwing deprecation warnings. Now it is. Apps should use Module#thread_mattr_accessor instead.

26 people contributed to Rails since the last time. All the changes can be checked here. Until next week!