aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
diff options
context:
space:
mode:
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.rb17
1 files changed, 4 insertions, 13 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 4608ffad67..4f67b02d00 100644
--- a/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
+++ b/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
@@ -2,19 +2,6 @@ module ActiveRecord
# = Active Record Belongs To Polymorphic Association
module Associations
class BelongsToPolymorphicAssociation < BelongsToAssociation #:nodoc:
- def stale_target?
- if @target && @target.persisted?
- target_id = @target.send(@reflection.association_primary_key).to_s
- foreign_key = @owner.send(@reflection.foreign_key).to_s
- target_type = @target.class.base_class.name
- foreign_type = @owner.send(@reflection.foreign_type).to_s
-
- target_id != foreign_key || target_type != foreign_type
- else
- false
- end
- end
-
private
def replace_keys(record)
@@ -38,6 +25,10 @@ module ActiveRecord
def raise_on_type_mismatch(record)
# A polymorphic association cannot have a type mismatch, by definition
end
+
+ def stale_state
+ [super, @owner[@reflection.foreign_type].to_s]
+ end
end
end
end