Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use relation#delete_all for Model.delete_all

  • Loading branch information...
commit 13989ff8c690b9b9e5282bd4098666c909ea64d3 1 parent 54b80c7
@lifo lifo authored
View
6 activerecord/lib/active_record/base.rb
@@ -939,11 +939,7 @@ def destroy_all(conditions = nil)
# Both calls delete the affected posts all at once with a single DELETE statement. If you need to destroy dependent
# associations or call your <tt>before_*</tt> or +after_destroy+ callbacks, use the +destroy_all+ method instead.
def delete_all(conditions = nil)
- if conditions
- arel_table.where(Arel::SqlLiteral.new(construct_conditions(conditions, scope(:find)))).delete
- else
- arel_table.delete
- end
+ arel_table.where(construct_conditions(conditions, scope(:find))).delete_all
end
# Returns the result of an SQL statement that should only include a COUNT(*) in the SELECT part.
View
3  activerecord/lib/active_record/relation.rb
@@ -225,8 +225,7 @@ def destroy_all
end
def delete_all
- @relation.delete
- reset
+ @relation.delete.tap { reset }
end
def loaded?

0 comments on commit 13989ff

Please sign in to comment.
Something went wrong with that request. Please try again.