diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-08 22:39:58 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-08 22:39:58 +0900 |
commit | e133573c8195f088ce29fbebabe3428cff9dc20d (patch) | |
tree | e2d78c929967a908f6c96823887cb630d57ffead /activerecord/lib/active_record | |
parent | 4cb1438b57067d637c79d49d0662c43b5b4e64c2 (diff) | |
parent | 7f153e936af6ae2ac1809e5758000aaf003a1f62 (diff) | |
download | rails-e133573c8195f088ce29fbebabe3428cff9dc20d.tar.gz rails-e133573c8195f088ce29fbebabe3428cff9dc20d.tar.bz2 rails-e133573c8195f088ce29fbebabe3428cff9dc20d.zip |
Merge pull request #35178 from bogdan/has-many-size
Bugfix has_many association #size when ids reader is cached and assoc…
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 68f53d5c1c..b0c0beac0e 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -347,7 +347,6 @@ module ActiveRecord add_to_target(record) do result = insert_record(record, true, raise) { @_was_loaded = loaded? - @association_ids = nil } end raise ActiveRecord::Rollback unless result @@ -384,6 +383,7 @@ module ActiveRecord delete_records(existing_records, method) if existing_records.any? @target -= records + @association_ids = nil records.each { |record| callback(:after_remove, record) } end @@ -424,7 +424,6 @@ module ActiveRecord unless owner.new_record? result &&= insert_record(record, true, raise) { @_was_loaded = loaded? - @association_ids = nil } end end @@ -447,6 +446,7 @@ module ActiveRecord if index target[index] = record elsif @_was_loaded || !loaded? + @association_ids = nil target << record end |