aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-12-29 11:45:25 +0530
committerPratik Naik <pratiknaik@gmail.com>2009-12-29 11:46:07 +0530
commit13989ff8c690b9b9e5282bd4098666c909ea64d3 (patch)
tree15e6e03709e179b1b8f5b02f60b4e701bce5f9c9 /activerecord
parent54b80c73611fe8eb19039381bf0322326f5e1b51 (diff)
downloadrails-13989ff8c690b9b9e5282bd4098666c909ea64d3.tar.gz
rails-13989ff8c690b9b9e5282bd4098666c909ea64d3.tar.bz2
rails-13989ff8c690b9b9e5282bd4098666c909ea64d3.zip
Use relation#delete_all for Model.delete_all
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/base.rb6
-rw-r--r--activerecord/lib/active_record/relation.rb3
2 files changed, 2 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 53f0a920a3..6715871bf9 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -939,11 +939,7 @@ module ActiveRecord #:nodoc:
# 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.
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index a3d7be3afe..c6c63291c9 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -225,8 +225,7 @@ module ActiveRecord
end
def delete_all
- @relation.delete
- reset
+ @relation.delete.tap { reset }
end
def loaded?