diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-06-11 14:41:33 -0400 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-06-11 15:03:32 -0400 |
commit | 832b7a7ca330a38235d9bdecb18fa9dbf4ed156f (patch) | |
tree | 40db7275a422c942317c30ddffdd58a31bda84ce /activerecord/lib | |
parent | b05bcb8fef706ef45e2f273040083b1bbd180c6e (diff) | |
download | rails-832b7a7ca330a38235d9bdecb18fa9dbf4ed156f.tar.gz rails-832b7a7ca330a38235d9bdecb18fa9dbf4ed156f.tar.bz2 rails-832b7a7ca330a38235d9bdecb18fa9dbf4ed156f.zip |
Don't use `target=`
It mark the association as loaded and this can cause the object to be in
an stale state.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 9a90cd2cc7..840d900bbc 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -400,7 +400,7 @@ module ActiveRecord records.each { |record| callback(:before_remove, record) } delete_records(existing_records, method) if existing_records.any? - self.target -= records + @target -= records records.each { |record| callback(:after_remove, record) } end |