diff options
Diffstat (limited to 'activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb b/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb index 13b4a084ea..75b4c4481a 100644 --- a/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +++ b/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module ActiveRecord - # = Active Record Belongs To Polymorphic Association module Associations + # = Active Record Belongs To Polymorphic Association class BelongsToPolymorphicAssociation < BelongsToAssociation #:nodoc: def klass type = owner[reflection.foreign_type] @@ -13,12 +13,7 @@ module ActiveRecord def replace_keys(record) super - owner[reflection.foreign_type] = record.class.base_class.name - end - - def remove_keys - super - owner[reflection.foreign_type] = nil + owner[reflection.foreign_type] = record ? record.class.polymorphic_name : nil end def different_target?(record) |