This Week in Rails

December 6, 2024

SQLite3 extensions loading and more

Hi, Wojtek here. Let’s explore this week’s news in the Rails. 🎅

Getting started tutorial
New pull request up for a community review: the new Getting Started tutorial shows you how to build an e-commerce app using all of Rails 8’s features out of the box - straight through to deployment. This will be the flagship tutorial to guide new Rails devs for years to come, so we’d love your feedback.

The Rails Foundation welcomes 1Password as Core member
Expanding Core membership means a stronger foundation with more long-term growth and sustainability, and most importantly: more support for the Rails community.

Support loading SQLite3 extensions
The sqlite3 gem v2.4.0 introduces support for loading extensions passed as a kwarg to Database.new. This PR leverages that feature to allow configuration of extensions in the config/database.yml file using either filesystem paths or the names of modules that respond to to_path method.

Shard selector support for granular database connection switching
A new configuration option, class_name, is introduced to config.active_record.shard_selector to allow an application to specify the abstract connection class to be switched by the shard selection middleware. The default class is ActiveRecord::Base. For example, this configuration tells ShardSelector to switch shards using AnimalsRecord.connected_to:

config.active_record.shard_selector = { class_name: "AnimalsRecord" }

Action Controller Overview and Advanced Topics Guides

It updates the Action Controller Overview Rails Guide, as well as creates a new guide called “Action Controller Advanced Topics”. Can be previewed on the edge guides.

Don’t wrap redis in ConnectionPool twice
Avoid wrapping redis in a ConnectionPool when using ActiveSupport::Cache::RedisCacheStore if the :redis option is already a ConnectionPool.

Add CSP nonce to preload links
Preload link tags need the CSP nonce added if the policy is configured with a nonce, otherwise browsers won’t load these resources.

Use _N as a parallel tests databases suffixes
Peviously, -N was used as a suffix, which caused problems for RDBMSes which do not support dashes in database names.

Reset relations after insert_all/upsert_all
Bulk insert/upsert methods will now call reset if used on a relation, matching the behavior of update_all method.

You can view the whole list of changes here. We had 29 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.