Skip to content
  • Sean Doyle's avatar
    2c57ec6a
    Include `ActiveModel::API` in `ActiveRecord::Base` · 2c57ec6a
    Sean Doyle authored
    `ActiveRecord::Base` does not (and has never) inherit from
    `ActiveModel::Model`.
    
    `ActiveModel::API` was introduced in as an extraction from
    `ActiveModel::Model`. At that time (Sep 15, 2021), it was included back
    into `ActiveModel::Model`, but was never included in `ActiveRecord` at
    all.
    
    The intent communicated around the introduction of `ActiveModel::API`
    stated:
    
    > By moving `ActiveModel::Model`'s implementation to a new
    > `ActiveModel::API` we keep a definition of the minimum API to talk with
    > Action Pack and Action View.
    
    Active Record is also designed to integrate with Action Pack and Action
    View. It already does (and its integration predates `ActiveModel::API`
    by more than a decade). It's integration is powered by including and
    extending the same set of foundational modules, with some
    database-specific overrides.
    
    This commit adds an `include ActiveModel::API` statement to
    `ActiveRecord::Base`, then re-structures those overrides to comply with
    the new module resolution order.
    
    [c477d956]: https://github.com/rails/rails/commit/c477d95604e80e04d1aa8113a8236353235eb86a
    2c57ec6a
    Include `ActiveModel::API` in `ActiveRecord::Base`
    Sean Doyle authored
    `ActiveRecord::Base` does not (and has never) inherit from
    `ActiveModel::Model`.
    
    `ActiveModel::API` was introduced in as an extraction from
    `ActiveModel::Model`. At that time (Sep 15, 2021), it was included back
    into `ActiveModel::Model`, but was never included in `ActiveRecord` at
    all.
    
    The intent communicated around the introduction of `ActiveModel::API`
    stated:
    
    > By moving `ActiveModel::Model`'s implementation to a new
    > `ActiveModel::API` we keep a definition of the minimum API to talk with
    > Action Pack and Action View.
    
    Active Record is also designed to integrate with Action Pack and Action
    View. It already does (and its integration predates `ActiveModel::API`
    by more than a decade). It's integration is powered by including and
    extending the same set of foundational modules, with some
    database-specific overrides.
    
    This commit adds an `include ActiveModel::API` statement to
    `ActiveRecord::Base`, then re-structures those overrides to comply with
    the new module resolution order.
    
    [c477d956]: https://github.com/rails/rails/commit/c477d95604e80e04d1aa8113a8236353235eb86a
Loading