The Active Record has been improved to invert rename_enum_value when :from/:to are provided, prevent persisting invalid records, and handle errors during connection configuration. Additionally, the SQLite3 adapter has been fixed to quote non-finite Numeric values like "Infinity" and "NaN". The update also addresses issues with libpq returning a database version of 0 on no/bad connections in PostgreSQLAdapter, handling errors during the connection configuration phase, and handling circular references when autosaving associations. The changes aim to improve Ruby on Rails' overall performance and maintainability.
Rails 8.0.2
Active Support
Fix setting
to_time_preserves_timezonefromnew_framework_defaults_8_0.rb.fatkodima
Fix Active Support Cache
fetch_multiwhen local store is active.
fetch_multinow properly yield to the provided block for missing entries
that have been recorded as such in the local store.Jean Boussier
Fix execution wrapping to report all exceptions, including
Exception.If a more serious error like
SystemStackErrororNoMemoryErrorhappens,
the error reporter should be able to report these kinds of exceptions.Gannon McGibbon
Fix
RedisCacheStoreandMemCacheStoreto also handle connection pool related errors.These errors are rescued and reported to
Rails.error.Jean Boussier
Fix
ActiveSupport::Cache#read_multito respect version expiry when using local cache.zzak
Fix
ActiveSupport::MessageVerifierandActiveSupport::MessageEncryptorconfiguration ofon_rotationcallback.verifier.rotate(old_secret).on_rotation { ... }Now both work as documented.
Jean Boussier
Fix
ActiveSupport::MessageVerifierto always be able to verify both URL-safe and URL-unsafe payloads.This is to allow transitioning seemlessly from either configuration without immediately invalidating
all previously generated signed messages.Jean Boussier, Florent Beaurain, Ali Sepehri
Fix
cache.fetchto honor the provided expiry when:race_condition_ttlis used.cache.fetch("key", expires_in: 1.hour, race_condition_ttl: 5.second) do "something" endIn the above example, the final cache entry would have a 10 seconds TTL instead
of the requested 1 hour.Dhia
Better handle procs with splat arguments in
set_callback.Radamés Roriz
Fix
String#mb_charsto not mutate the receiver.Previously it would call
force_encodingon the receiver,
now it dups the receiver first.Jean Boussier
Improve
ErrorSubscriberto also mark error causes as reported.This avoid some cases of errors being reported twice, notably in views because of how
errors are wrapped inActionView::Template::Error.Jean Boussier
Fix
Module#module_parent_nameto return the correct name after the module has been named.When called on an anonymous module, the return value wouldn't change after the module was given a name
later by being assigned to a constant.mod = Module.new mod.module_parent_name # => "Object" MyModule::Something = mod mod.module_parent_name # => "MyModule"Jean Boussier
Active Model
- No changes.
Active Record
Fix inverting
rename_enum_valuewhen:from/:toare provided.fatkodima
Prevent persisting invalid record.
Edouard Chin
Fix inverting
drop_tablewithout options.fatkodima
Fix count with group by qualified name on loaded relation.
Ryuta Kamizono
Fix
sumwith qualified name on loaded relation.Chris Gunther
The SQLite3 adapter quotes non-finite Numeric values like "Infinity" and "NaN".
Mike Dalessio
Handle libpq returning a database version of 0 on no/bad connection in
PostgreSQLAdapter.Before, this version would be cached and an error would be raised during connection configuration when
comparing it with the minimum required version for the adapter. This meant that the connection could
never be successfully configured on subsequent reconnection attempts.Now, this is treated as a connection failure consistent with libpq, raising a
ActiveRecord::ConnectionFailed
and ensuring the version isn't cached, which allows the version to be retrieved on the next connection attempt.Joshua Young, Rian McGuire
Fix error handling during connection configuration.
Active Record wasn't properly handling errors during the connection configuration phase.
This could lead to a partially configured connection being used, resulting in various exceptions,
the most common being with the PostgreSQLAdapter raisingundefined methodkey?' for nilorTypeError: wrong argument type nil (expected PG::TypeMap)`.Jean Boussier
Fix a case where a non-retryable query could be marked retryable.
Hartley McGuire
Handle circular references when autosaving associations.
zzak
PoolConfig no longer keeps a reference to the connection class.
Keeping a reference to the class caused subtle issues when combined with reloading in
development. Fixes #54343.Mike Dalessio
Fix SQL notifications sometimes not sent when using async queries.
Post.async_count ActiveSupport::Notifications.subscribed(->(*) { "Will never reach here" }) do Post.count endIn rare circumstances and under the right race condition, Active Support notifications
would no longer be dispatched after using an asynchronous query.
This is now fixed.Edouard Chin
Fix support for PostgreSQL enum types with commas in their name.
Arthur Hess
Fix inserts on MySQL with no RETURNING support for a table with multiple auto populated columns.
Nikita Vasilevsky
Fix joining on a scoped association with string joins and bind parameters.
class Instructor < ActiveRecord::Base has_many :instructor_roles, -> { active } end class InstructorRole < ActiveRecord::Base scope :active, -> { joins("JOIN students ON instructor_roles.student_id = students.id") .where(students { status: 1 }) } end Instructor.joins(:instructor_roles).firstThe above example would result in
ActiveRecord::StatementInvalidbecause theactivescope bind parameters would be lost.Jean Boussier
Fix a potential race condition with system tests and transactional fixtures.
Sjoerd Lagarde
Fix autosave associations to no longer validated unmodified associated records.
Active Record was incorrectly performing validation on associated record that
weren't created nor modified as part of the transaction:Post.create!(author: User.find(1)) # Fail if user is invalidJean Boussier
Remember when a database connection has recently been verified (for
two seconds, by default), to avoid repeated reverifications during a
single request.This should recreate a similar rate of verification as in Rails 7.1,
where connections are leased for the duration of a request, and thus
only verified once.Matthew Draper
Action View
Respect
html_options[:form]whencollection_checkboxesgenerates the
hidden<input>.Riccardo Odone
Layouts have access to local variables passed to
render.This fixes #31680 which was a regression in Rails 5.1.
Mike Dalessio
Argument errors related to strict locals in templates now raise an
ActionView::StrictLocalsError, and all other argument errors are reraised as-is.Previously, any
ArgumentErrorraised during template rendering was swallowed during strict
local error handling, so that anArgumentErrorunrelated to strict locals (e.g., a helper
method invoked with incorrect arguments) would be replaced by a similarArgumentErrorwith an
unrelated backtrace, making it difficult to debug templates.Now, any
ArgumentErrorunrelated to strict locals is reraised, preserving the original
backtrace for developers.Also note that
ActionView::StrictLocalsErroris a subclass ofArgumentError, so any existing
code that rescuesArgumentErrorwill continue to work.Fixes #52227.
Mike Dalessio
Fix stack overflow error in dependency tracker when dealing with circular dependencies
Jean Boussier
Action Pack
Improve
with_routingtest helper to not rebuild the middleware stack.Otherwise some middleware configuration could be lost.
Édouard Chin
Add resource name to the
ArgumentErrorthat's raised when invalid:onlyor:exceptoptions are given to#resourceor#resourcesThis makes it easier to locate the source of the problem, especially for routes drawn by gems.
Before:
:only and :except must include only [:index, :create, :new, :show, :update, :destroy, :edit], but also included [:foo, :bar]After:
Route `resources :products` - :only and :except must include only [:index, :create, :new, :show, :update, :destroy, :edit], but also included [:foo, :bar]Jeremy Green
Fix
url_forto handle:path_paramsgracefully when it's not aHash.Prevents various security scanners from causing exceptions.
Martin Emde
Fix
ActionDispatch::Executorto unwrap exceptions like other error reporting middlewares.Jean Boussier
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Active Storage
A Blob will no longer autosave associated Attachment.
This fixes an issue where a record with an attachment would have
its dirty attributes reset, preventing yourafter commitcallbacks
on that record to behave as expected.Note that this change doesn't require any changes on your application
and is supposed to be internal. Active Storage Attachment will continue
to be autosaved (through a different relation).Edouard-chin
Action Mailbox
- No changes.
Action Text
- No changes.
Railties
Fix Rails console to load routes.
Otherwise
*_pathand*urlmethods are missing on theappobject.Édouard Chin
Update
rails new --minimaloptionExtend the
--minimalflag to exclude recently added features:skip_brakeman,skip_ci,skip_docker,skip_kamal,skip_rubocop,skip_solidandskip_thruster.eelcoj
Use
secret_key_basefrom ENV or credentials when present locally.When ENV["SECRET_KEY_BASE"] or
Rails.application.credentials.secret_key_baseis set for test or
development, it is used for theRails.config.secret_key_base,
instead of generating atmp/local_secret.txtfile.Petrik de Heus
Guides
- No changes.
