diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-12-04 15:47:00 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-04 15:47:00 +0900 |
commit | 53d5a682c90b20a35cfc44d4f0e267ee94321e8f (patch) | |
tree | 6eb2dd1ff18c3380f633446394f9b78c275ec680 /activerecord/lib | |
parent | 6ca6478a67ecdff58c29d10cd408b7259ed89e2b (diff) | |
parent | 67bca35a64e0fde994270b242f0b1c59d8e56b0b (diff) | |
download | rails-53d5a682c90b20a35cfc44d4f0e267ee94321e8f.tar.gz rails-53d5a682c90b20a35cfc44d4f0e267ee94321e8f.tar.bz2 rails-53d5a682c90b20a35cfc44d4f0e267ee94321e8f.zip |
Merge pull request #34607 from gmcgibbon/clear_scope_on_delete
Reset scope after collection delete
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 811fbfd927..4fbbc713e4 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -500,7 +500,7 @@ module ActiveRecord # Pet.find(1, 2, 3) # # => ActiveRecord::RecordNotFound: Couldn't find all Pets with 'id': (1, 2, 3) def delete_all(dependent = nil) - @association.delete_all(dependent) + @association.delete_all(dependent).tap { reset_scope } end # Deletes the records of the collection directly from the database @@ -527,7 +527,7 @@ module ActiveRecord # # Pet.find(1) # => Couldn't find Pet with id=1 def destroy_all - @association.destroy_all + @association.destroy_all.tap { reset_scope } end # Deletes the +records+ supplied from the collection according to the strategy @@ -646,7 +646,7 @@ module ActiveRecord # # #<Pet id: 3, name: "Choo-Choo", person_id: 1> # # ] def delete(*records) - @association.delete(*records) + @association.delete(*records).tap { reset_scope } end # Destroys the +records+ supplied and removes them from the collection. @@ -718,7 +718,7 @@ module ActiveRecord # # Pet.find(4, 5, 6) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with 'id': (4, 5, 6) def destroy(*records) - @association.destroy(*records) + @association.destroy(*records).tap { reset_scope } end ## |