gems activemodel 8.0.2

12 hours ago

Active Support

  • Fix setting to_time_preserves_timezone from new_framework_defaults_8_0.rb.

    fatkodima

  • Fix Active Support Cache fetch_multi when local store is active.

    fetch_multi now 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 SystemStackError or NoMemoryError happens,
    the error reporter should be able to report these kinds of exceptions.

    Gannon McGibbon

  • Fix RedisCacheStore and MemCacheStore to also handle connection pool related errors.

    These errors are rescued and reported to Rails.error.

    Jean Boussier

  • Fix ActiveSupport::Cache#read_multi to respect version expiry when using local cache.

    zzak

  • Fix ActiveSupport::MessageVerifier and ActiveSupport::MessageEncryptor configuration of on_rotation callback.

    verifier.rotate(old_secret).on_rotation { ... }

    Now both work as documented.

    Jean Boussier

  • Fix ActiveSupport::MessageVerifier to 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.fetch to honor the provided expiry when :race_condition_ttl is used.

    cache.fetch("key", expires_in: 1.hour, race_condition_ttl: 5.second) do
      "something"
    end

    In 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_chars to not mutate the receiver.

    Previously it would call force_encoding on the receiver,
    now it dups the receiver first.

    Jean Boussier

  • Improve ErrorSubscriber to also mark error causes as reported.

    This avoid some cases of errors being reported twice, notably in views because of how
    errors are wrapped in ActionView::Template::Error.

    Jean Boussier

  • Fix Module#module_parent_name to 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_value when :from/:to are provided.

    fatkodima

  • Prevent persisting invalid record.

    Edouard Chin

  • Fix inverting drop_table without options.

    fatkodima

  • Fix count with group by qualified name on loaded relation.

    Ryuta Kamizono

  • Fix sum with 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 raising undefined method key?' 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
    end

    In 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).first

    The above example would result in ActiveRecord::StatementInvalid because the
    active scope 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 invalid

    Jean 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] when collection_checkboxes generates 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 ArgumentError raised during template rendering was swallowed during strict
    local error handling, so that an ArgumentError unrelated to strict locals (e.g., a helper
    method invoked with incorrect arguments) would be replaced by a similar ArgumentError with an
    unrelated backtrace, making it difficult to debug templates.

    Now, any ArgumentError unrelated to strict locals is reraised, preserving the original
    backtrace for developers.

    Also note that ActionView::StrictLocalsError is a subclass of ArgumentError, so any existing
    code that rescues ArgumentError will 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_routing test helper to not rebuild the middleware stack.

    Otherwise some middleware configuration could be lost.

    Édouard Chin

  • Add resource name to the ArgumentError that's raised when invalid :only or :except options are given to #resource or #resources

    This 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_for to handle :path_params gracefully when it's not a Hash.

    Prevents various security scanners from causing exceptions.

    Martin Emde

  • Fix ActionDispatch::Executor to 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 your after commit callbacks
    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 *_path and *url methods are missing on the app object.

    Édouard Chin

  • Update rails new --minimal option

    Extend the --minimal flag to exclude recently added features:
    skip_brakeman, skip_ci, skip_docker, skip_kamal, skip_rubocop, skip_solid and skip_thruster.

    eelcoj

  • Use secret_key_base from ENV or credentials when present locally.

    When ENV["SECRET_KEY_BASE"] or
    Rails.application.credentials.secret_key_base is set for test or
    development, it is used for the Rails.config.secret_key_base,
    instead of generating a tmp/local_secret.txt file.

    Petrik de Heus

Guides

  • No changes.

Don't miss a new activemodel release

NewReleases is sending notifications on new releases.