From 2c2ccec1c0f4712b45a50610f813661a112443ea Mon Sep 17 00:00:00 2001 From: Jonathan Hefner Date: Fri, 3 Nov 2023 10:58:38 -0500 Subject: [PATCH] Fix method visibility in ActiveRecord::Attributes Follow-up to #44666. `ActiveRecord::ModelSchema#reload_schema_from_cache` is protected and `ActiveModel::AttributeRegistration#reset_default_attributes` is private, so their overrides in `ActiveRecord::Attributes` should match those visibilities. --- activerecord/lib/active_record/attributes.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/activerecord/lib/active_record/attributes.rb b/activerecord/lib/active_record/attributes.rb index ae490d7fc077d..7715e4f3d99f0 100644 --- a/activerecord/lib/active_record/attributes.rb +++ b/activerecord/lib/active_record/attributes.rb @@ -249,12 +249,11 @@ def _default_attributes # :nodoc: end end - def reload_schema_from_cache(*) - reset_default_attributes! - super - end - - alias :reset_default_attributes :reload_schema_from_cache + protected + def reload_schema_from_cache(*) + reset_default_attributes! + super + end private NO_DEFAULT_PROVIDED = Object.new # :nodoc: @@ -276,6 +275,10 @@ def define_default_attribute(name, value, type, from_user:) _default_attributes[name] = default_attribute end + def reset_default_attributes + reload_schema_from_cache + end + def resolve_type_name(name, **options) Type.lookup(name, **options, adapter: Type.adapter_name_from(self)) end