aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
diff options
context:
space:
mode:
authorlarrylv <larrylv1990@gmail.com>2013-03-04 17:38:22 +0800
committerlarrylv <larrylv1990@gmail.com>2013-03-05 12:43:05 +0800
commit939b896a06c0cff661076d0ca3fbe8c1d5552e83 (patch)
treefeec62302e70bfaf86c85e3537456487d94352a2 /activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
parent927e649bc9dc5740285e4b4e9899421c2bbfefbe (diff)
downloadrails-939b896a06c0cff661076d0ca3fbe8c1d5552e83.tar.gz
rails-939b896a06c0cff661076d0ca3fbe8c1d5552e83.tar.bz2
rails-939b896a06c0cff661076d0ca3fbe8c1d5552e83.zip
Fix issue #7526. Reload the target if it's stale.
* This has been fixed at master via `365b8b6`, but not at 3-2-stable branch. * @stale_state should be nil when a model isn't saved. via `0f3901e`. * set @stale_state to nil when reset the target.
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.rb3
1 files changed, 2 insertions, 1 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 2ee5dbbd70..88ce03a3cd 100644
--- a/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
+++ b/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
@@ -27,7 +27,8 @@ module ActiveRecord
end
def stale_state
- [super, owner[reflection.foreign_type].to_s]
+ foreign_key = super
+ foreign_key && [foreign_key.to_s, owner[reflection.foreign_type].to_s]
end
end
end