mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
refactor and clean up delete_all method
Now that delete_all with destroy or delete_all dependency behave the same we no longer need this conditional. This means we can remove the new delete_all_with_dependency method I added and go straight to delete_records from delete_all, passing :all and the dependent directly.
This commit is contained in:
parent
b6bab2af14
commit
255de98a9a
1 changed files with 1 additions and 9 deletions
|
@ -194,7 +194,7 @@ module ActiveRecord
|
||||||
options[:dependent]
|
options[:dependent]
|
||||||
end
|
end
|
||||||
|
|
||||||
delete_all_with_dependency(dependent).tap do
|
delete_records(:all, dependent).tap do
|
||||||
reset
|
reset
|
||||||
loaded!
|
loaded!
|
||||||
end
|
end
|
||||||
|
@ -251,14 +251,6 @@ module ActiveRecord
|
||||||
delete_or_destroy(records, dependent)
|
delete_or_destroy(records, dependent)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_all_with_dependency(dependent)
|
|
||||||
if dependent == :destroy
|
|
||||||
delete_or_destroy(load_target, dependent)
|
|
||||||
else
|
|
||||||
delete_records(:all, dependent)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Deletes the +records+ and removes them from this association calling
|
# Deletes the +records+ and removes them from this association calling
|
||||||
# +before_remove+ , +after_remove+ , +before_destroy+ and +after_destroy+ callbacks.
|
# +before_remove+ , +after_remove+ , +before_destroy+ and +after_destroy+ callbacks.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue