diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2017-12-27 15:52:35 +0200 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2017-12-27 15:58:09 +0200 |
commit | a84c76573fa776e377c087930dcbdc3a07eb8603 (patch) | |
tree | 7ffd45b7ba527905a30799a8fa056cd90d5a8b3c /activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb | |
parent | 17ad4eb6fb25e0c1dbd6772718a9097d63b64ad2 (diff) | |
download | rails-a84c76573fa776e377c087930dcbdc3a07eb8603.tar.gz rails-a84c76573fa776e377c087930dcbdc3a07eb8603.tar.bz2 rails-a84c76573fa776e377c087930dcbdc3a07eb8603.zip |
Bugfix foreign key replacement in inverse association
when model is added to collection association
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 | 7 |
1 files changed, 1 insertions, 6 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 4ce3474bd5..55d789c66a 100644 --- a/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +++ b/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb @@ -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.base_class.name : nil end def different_target?(record) |