aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/base.rb2
-rw-r--r--activerecord/lib/active_record/relation.rb12
2 files changed, 12 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index a3b123c463..cad75f80e5 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -914,7 +914,7 @@ module ActiveRecord #:nodoc:
# Person.destroy_all("last_login < '2004-04-04'")
# Person.destroy_all(:status => "inactive")
def destroy_all(conditions = nil)
- where(conditions).each {|object| object.destroy }
+ where(conditions).destroy_all
end
# Deletes the records matching +conditions+ without instantiating the records first, and hence not
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index bec9a88297..4aa460a601 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -175,13 +175,23 @@ module ActiveRecord
end
end
+ def destroy_all
+ to_a.each {|object| object.destroy}
+ reset
+ end
+
def loaded?
@loaded
end
def reload
@loaded = false
- @records = @first = @last = nil
+ reset
+ end
+
+ def reset
+ @first = @last = nil
+ @records = []
self
end