Friday, November 21, 2025

This Week in Rails: November 21, 2025

Posted by zzak

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

Add support for per-adapter migration strategy
You can now set migration_strategy on individual adapter classes, overriding the global ActiveRecord.migration_strategy. This allows individual databases to customize migration execution logic:

class CustomPostgresStrategy < ActiveRecord::Migration::DefaultStrategy
  def drop_table(*)
    # Custom logic specific to PostgreSQL
  end
end

ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.migration_strategy = CustomPostgresStrategy

Make explain accept hash format syntax
This PR changes EXPLAIN clause building for MySQL and PostgreSQL adapters to accept options in hash format. This allows more flexibility when specifying options such as the output format.

Car.all.explain(format: :json)
# or
Car.connection.explain(query, [], [{format: :json}]
# will generate the proper `FORMAT=JSON` on MySQL or `FORMAT JSON` on PostgreSQL

Fast failure mode for local CI
This PR introduces a cli argument --fail-fast (or -f), as commonly used by for example minitest and RSpec.

Support text/markdown format in DebugExceptions middleware
Add support for returning markdown-formatted error responses when the HTTP client prefers text/markdown in the Accept header. When text/markdown is requested, the middleware renders the existing text templates with Content-Type: text/markdown instead of text/html. This allows CLI tools (e.g., Claude Code) and other clients to receive byte/token-efficient error output in markdown format.

Implement LocalCache strategy on MemoryStore
This PR simply prepends Strategy::LocalCache to ActiveSupport::Cache::MemoryStore which adds common behavior for cache stores. The memory store needs to respond to the same interface as other cache stores (e.g. ActiveSupport::NullStore).

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

Until next time!

Subscribe to get these updates mailed to you.