Hi, it’s Greg. Let’s explore this week’s changes in the Rails codebase.
Update the default Bun version to 1.4.5 for new applications
The fallback Bun version for new applications is updated from 1.0.1 to 1.4.5, used for ARG BUN_VERSION in the generated Dockerfile and bun-version in ci.yml when Bun is not installed locally.
Hide generator-only flags from rails plugin new –help
PluginGenerator inherits --skip-namespace and --skip-collision-check from Rails::Generators::Base, even though those flags only apply inside an existing app or engine. Both flags are now hidden from rails plugin new --help, matching rails new --help, while still being accepted for compatibility.
Fix line filtering of tests with a method call on their first line
bin/rails test FILE:LINE ran no tests when pointing to a body line of a test whose opening line contained another method call, such as test "parses #{format.upcase}" do. Every line of the test selects it again.
Fix reverting t.change_default with :from and :to
Reverting a migration that used t.change_default inside change_table raised ActiveRecord::IrreversibleMigration even when :from and :to were given. The same happened when passing { from: ..., to: ... } as a positional hash to change_column_default, change_column_comment, or change_table_comment. All of these are reversible again.
Reset the JS fallback when view formats change
Assigning :js to LookupContext#formats= enables an implicit HTML fallback, and that flag lingered across later format assignments, so a nested partial inside an XML template could render as HTML. Assigning new formats now recomputes and clears the fallback.
Fix first(n) on ordered disable_joins association scopes
When an intermediate association determines the order on a scoped disable_joins association, Active Record sorts the loaded records in Ruby. Calling first(n) then called limit on that Array and raised NoMethodError. It now slices the array and returns up to n records in order.
Fix Journey::Scanner lexing of literal : and *
After a recent scanner optimization, bare : and * or ones followed by non-word characters (such as "/foo:", "/foo:-bar", or "/*") were tokenized as :SYMBOL or :STAR instead of literals, and a trailing : raised a TypeError. The scanner now only emits :SYMBOL or :STAR when at least one word character follows.
Call from_node for Action Text attachables located in bulk
Bulk attachable loading skipped ActionText::Attachable.from_node for records found by the bulk query, bypassing application overrides of Attachable.from_node and Attachment.from_node. Content#attachables and attachment construction call from_node for every node again while still reusing the bulk-loaded records.
Relax Action View’s Prism version constraint
This change removes the version constraint on the prism dependency in Action View’s gemspec to match Railties, allowing applications to use newer versions of Prism.
Fix interrupt_job_during_step with non-primitive cursors
interrupt_job_during_step only interrupted a job when cursor: was a primitive like an Integer, String, or Array of them, letting jobs with Date, Time, Symbol, Hash, or GlobalID cursors run to completion. It now works with any serializable cursor object again.
Render the alt text of Action Text remote image attachments
Action Text rendered the alt attribute for Active Storage blob images, but dropped it for remote image attachments. Remote image <action-text-attachment> tags now render their alt text on the <img> tag too:
<figure class="attachment attachment--preview">
<img alt="A racecar on a track" src="https://example.com/racecar.jpg">
</figure>
Fix scaffold –model-name for a non-namespaced controller
Running bin/rails generate scaffold_controller account --model-name=user without a namespace produced broken code such as redirect_to [, @user] and _users_path because controller_class_path is empty. Empty namespaces are now skipped so it generates @user and users_path.
Scrub the invalid parameter key before using it in the error
ParamBuilder#store_nested_param raises InvalidParameterError when a query string or form key is not valid UTF-8, and interpolating the raw key left the exception message itself with invalid encoding. The key is now scrubbed first, matching how invalid values and JSON keys are handled.
Add the STI type condition after merging the scope when preloading
When preloading an STI association whose scope had its own condition on the inheritance column (for example where.not(type: "SubSpecialComment")), merging the scope removed the STI type IN (...) condition and raised ActiveRecord::SubclassNotFound. The preloader now applies the STI type condition after merging the association scope.
Add the STI type conditions after merging the association scope
The same issue affected joining an STI association or loading a has_many :through chain where an intermediate STI association has a condition on the inheritance column. Type conditions are now added after merging the association scope so records from other STI classes are not returned.
Fix the API scaffold controller location with –model-name
Generating an API controller with a namespace and --model-name, like bin/rails generate scaffold_controller admin/user --model-name=user --api, omitted the namespace from location: in create and raised NoMethodError for user_url. It now generates location: [:admin, @user], matching the non-API scaffold template.
Make renderers added with ActionController::Renderers.add callable from non-main Ractors
ActionController::Renderers.add defined renderer methods directly from the given block, which raised RuntimeError when called from a non-main Ractor after Rails.application.ractorize!. It now wraps the block with ActiveSupport::Ractors.try_shareable_proc, allowing built-in and custom renderers like json: and turbo_stream: to run in Ractors.
Make exceptions middleware work with strict CSP
This pull request updates the development debug exception templates so they work under a strict Content Security Policy, such as when Turbo Drive renders an error page into a document that enforces CSP. Inline event handlers and style attributes are replaced with data-* listeners and CSS classes, nonces are added to <script> and <style> tags when a nonce generator is configured, and a csp-nonce meta tag is included for Turbo.
Fix remove_column ignoring algorithm: and lock: on MySQL
remove_column on MySQL dropped the algorithm: and lock: options instead of appending them to the ALTER TABLE statement. Both options are applied again:
ALTER TABLE `users` DROP COLUMN `name`, ALGORITHM = INPLACE, LOCK = NONE
Fix bin/rails credentials:keys showing a backtrace for an invalid key length
When RAILS_MASTER_KEY has an invalid length, bin/rails credentials:keys now prints a one-line error message and exits with status 1 instead of dumping a stack trace, matching the other credentials:* commands.
Fix bind variables with Arel.sql in sanitize_sql_array and find_by_sql
Passing an Arel.sql literal with bind variables in an array, such as Topic.find_by_sql([Arel.sql("SELECT * FROM topics WHERE id = ?"), 1]), raised ActiveRecord::PreparedStatementInvalid. sanitize_sql_array, find_by_sql, update_all, and count_by_sql now handle Arel.sql statements with binds the same way where does.
Don’t modify the headers given to follow_redirect!
follow_redirect! wrote HTTP_REFERER directly into the headers: hash passed by the caller, raising FrozenError on a frozen hash and leaking the referer into subsequent requests if the hash was reused. The caller’s hash is no longer mutated.
Don’t remove :prompt from the options given to select_tag
select_tag deleted :prompt in place from the options hash passed to it, raising FrozenError on a frozen hash and dropping the prompt when reusing the hash across calls. It now leaves the given options hash untouched.
Don’t convert last_modified to UTC in place in http_cache_forever
Passing a frozen Time to http_cache_forever(last_modified: ...) raised FrozenError because it converted the Time object to UTC in place. It now leaves the caller’s Time unchanged, matching fresh_when and stale?.
Find exclusion constraints by name alone when removing them
PostgreSQL normalizes the where: clause of an exclusion constraint when storing it, so remove_exclusion_constraint (or reverting an add_exclusion_constraint migration) failed to find the constraint when matching on its original options. Removal now looks up the exclusion constraint by name alone, matching check constraints.
Fix callbacks raising on a frozen Array of :if / :unless conditions
Passing a frozen Array to :if or :unless on controller, model, or validation callbacks raised FrozenError. Callback registration no longer mutates the array passed in.
Check the keys of JSON request parameters for valid encoding
JSON parameter parsing checked hash values for valid UTF-8 encoding, while leaving hash keys unchecked. Keys in JSON request bodies are now checked too, returning 400 Bad Request on invalid UTF-8 just like query string and form keys.
Fix collection options with a Proc for both value_method and selected
options_from_collection_for_select and collection_select accepted a Proc for value_method and a Proc for selected or disabled, except when both were Procs at the same time, which raised a TypeError. Passing Procs for both works now.
Fix bin/rails notes raising on invalid bytes in a Ruby file’s comment
bin/rails notes and /rails/info/notes raised ArgumentError: invalid byte sequence in UTF-8 when a Ruby file comment contained non-UTF-8 bytes. Invalid bytes are now replaced when extracting annotations, matching non-Ruby files.
Fix receive_inbound_email_from_fixture raising when given a status
Action Mailbox’s receive_inbound_email_from_fixture and receive_inbound_email_from_source test helpers didn’t forward keyword arguments like status: to their create_inbound_email_from_* counterparts, raising ArgumentError. Both helpers now forward keyword arguments, matching receive_inbound_email_from_mail.
Fix row_count and exception in sql.active_record for async queries
Queries executed in the background with load_async reported row_count: 0 in their sql.active_record notification payload and omitted :exception and :exception_object on failure. Async query notifications now include the same payload fields as foreground queries.
Fix Time.now(in:) raising inside travel_to
Calling Time.now(in: zone) inside travel_to, travel, or freeze_time raised ArgumentError: wrong number of arguments. The stubbed Time.now now accepts in: and returns the traveled time in the requested zone.
Let Attachment.from_node pick attachables the bulk lookup didn’t locate
When bulk-locating Action Text attachables, ActionText::Content fell back to Attachable.from_node before calling Attachment.from_node, so Attachment.from_node never received nil and custom overrides could no longer supply fallback attachables. Only records found by the bulk lookup are passed in now.
Keep the job in the execution context while its errors are handled
ExecutionContext.set(job: self) in Active Job now wraps perform_now rather than _perform_job, so the current job stays in the execution context while rescue_from handlers run and is still cleared once perform_now finishes.
Deprecate a blank password: in http_basic_authenticate_with
Passing a blank password: to http_basic_authenticate_with or http_basic_authenticate_or_request_with is now deprecated and will raise an ArgumentError in Rails 8.3. A blank password, such as ENV["PASSWORD"].to_s when the variable is unset, lets any request with the configured username and an empty password authenticate:
http_basic_authenticate_with name: "admin", password: ENV["PASSWORD"].to_s
# DEPRECATION WARNING: Passing a blank `password:` to `http_basic_authenticate_with` is deprecated ...
Return a UTC time from Time.rfc3339 for the “-00:00” offset
Active Support’s Time.rfc3339 now returns a UTC Time for strings with the "-00:00" offset as well as "Z", matching Ruby 4.1:
Time.rfc3339("2026-08-07T10:00:00-00:00")
# Before: 2026-08-07 10:00:00 +0000 (utc? => false)
# After: 2026-08-07 10:00:00 UTC (utc? => true)
"+00:00" still returns a Time with a fixed offset, as in Ruby.
Fix edit_polymorphic_path skipping an overridden polymorphic_path
Prefixed polymorphic URL helpers like edit_polymorphic_path and new_polymorphic_url bypassed polymorphic_path and polymorphic_url, ignoring overrides defined in helpers or controllers. All prefixed helpers delegate through polymorphic_path and polymorphic_url again.
Raise MissingAttributeError when validating a column that was not selected
After a recent change to read_attribute_for_validation, validating an Active Record model loaded with select treated unselected columns as nil instead of raising ActiveModel::MissingAttributeError, causing presence validations to fail rather than flagging the missing column. Columns are read directly again so MissingAttributeError is raised, while non-column attributes keep the nil fallback.
Don’t drop the STI type condition when joining
Reflection#join_scope now preserves the STI type condition when merging an association scope during a join, matching lazy loading.
Add broadcast to ActionCable::Connection::TestServer
ActionCable::Connection::TestServer#broadcast now delegates to the underlying server, so connection.broadcast goes through the test adapter and works with assert_broadcasts and assert_broadcast_on in channel and connection tests.
Make serialized attribute decorators Ractor-shareable
Active Record’s serialize and store attribute decorators can now be shared across Ractors. When unshareable_proc_action is set, custom coders are also passed through ActiveSupport::Ractors.try_make_shareable, freezing them when serialize is called.
Find SQLite tables by any ASCII case of their name in the schema readers
SQLite matches table names case-insensitively for ASCII characters, while the batched SQLite schema readers required an exact match, causing columns, indexes, and foreign_keys to fail when a model’s table_name differed in case from CREATE TABLE. Unmatched names now fall back to an ASCII case-insensitive lookup, preferring temporary tables and views.
Don’t freeze serialized column defaults
Freezing model default attributes cast each default once at schema load, which broke serialized attributes whose coder doesn’t round-trip the database default (for example, loading a NOT NULL {} JSONB default as [] and marking new records as changed). Models with serialize or encrypts wrapping a serialized type keep writable per-record defaults again.
Preserve unsafe status in SafeBuffer#encode, -@, dedup, and +@
Mutating a SafeBuffer in place with methods like gsub! marks it as not html_safe?, yet calling encode, -@, dedup, or +@ (on a frozen receiver) returned a buffer where html_safe? was true again, letting ERB render it unescaped. All four methods now preserve the unsafe flag.
Make Symbol#to_s return the interned frozen String on Ruby < 4.1
Symbol#to_s now returns Symbol#name, the symbol’s interned frozen String, on Rubies before 4.1, which made that change in Ruby itself (Feature #22137). Mutating the returned String raises FrozenError; Ruby 3.4 and 4.0 already warned about it.
Raise from ractorize! unless eager loading is enabled
Rails.application.ractorize! relies on class state computed during eager loading, and calling it with config.eager_load = false previously succeeded at boot only to fail with a FrozenError on the first request in a Ractor. ractorize! now raises right away unless config.eager_load is enabled.
Make fragment_cache_keys Ractor shareable
fragment_cache_keys is now frozen by default, and fragment_cache_key passes its blocks and values through ActiveSupport::Ractors.try_shareable_proc so controller fragment cache keys work across Ractors.
Adds locals when rendering Action Text attachments
You can now pass locals when rendering Action Text content:
<%= render @post.body, turbo_frame: :_top %>
Attachment partials can then read them from local_assigns, and to_editor_html also sets in_editor: true by default:
<%# app/views/users/_user.html.erb %>
<%= link_to user.name, user, data: { turbo_frame: local_assigns[:turbo_frame] } %>
Add named lock strengths to lock, lock! and with_lock
Passing a symbol to lock, lock!, or with_lock now requests a named row-lock strength, resolved by the database adapter:
Account.lock(:no_key_update).find(1) # SELECT ... FOR NO KEY UPDATE
account.with_lock(:share) { ... } # FOR SHARE / LOCK IN SHARE MODE
Supported strengths are :update (all adapters), :share (PostgreSQL and MySQL), and :no_key_update / :key_share (PostgreSQL). Passing an unsupported strength raises ArgumentError, whereas previously passing a symbol silently disabled locking. On PostgreSQL, :no_key_update gives the same writer-to-writer exclusion as FOR UPDATE without blocking FOR KEY SHARE foreign-key checks from child table inserts.
Raise a more descriptive error when file cannot be decrypted
This pull request introduces ActiveSupport::EncryptedConfiguration::DecryptionError so failed decryption of an encrypted configuration or credentials file tells you which file could not be decrypted, matching the error message from bin/rails credentials.
Fix duplicate after_commit callback registration for destroy_async in class inheritance
When both a parent model and its subclass declared associations with dependent: :destroy_async, the after_commit callback was registered twice and enqueued duplicate DestroyAssociationAsyncJob jobs. Active Record now checks the full inheritance chain before registering the callback.
Add ActiveStorage::Blob#pdf?
ActiveStorage::Blob#pdf? returns true when the blob’s content type is "application/pdf" or a PDF-based file like Illustrator, matching existing helpers like image?, audio?, video?, and text?.
Change form template to use button tag
The generated scaffold form template now renders a <button> tag instead of <input type="submit">. Because <button> allows child HTML elements, you can style loading states with CSS when Turbo disables the button on form submission.
You can view the whole list of changes here.
We had 34 contributors to the Rails codebase this past week!
Until next time!
Subscribe to get these updates mailed to you.