1
0
Fork 0
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:
eileencodes 2014-05-05 18:05:36 -04:00
parent b6bab2af14
commit 255de98a9a

View file

@ -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.
# #