Permalink
Browse files

Make Model.destroy_all use new finders

  • Loading branch information...
1 parent 352cc7c commit 5cd8818258cf7ce2c90667076d3f61f1c7ed548e @lifo lifo committed Dec 27, 2009
Showing with 3 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/base.rb
  2. +2 −0 activerecord/lib/active_record/relation.rb
@@ -914,7 +914,7 @@ def update_all(updates, conditions = nil, options = {})
# Person.destroy_all("last_login < '2004-04-04'")
# Person.destroy_all(:status => "inactive")
def destroy_all(conditions = nil)
- find(:all, :conditions => conditions).each { |object| object.destroy }
+ where(conditions).each {|object| object.destroy }
end
# Deletes the records matching +conditions+ without instantiating the records first, and hence not
@@ -88,6 +88,8 @@ def joins(join, join_type = nil)
end
def where(*args)
+ return create_new_relation if args.blank?
+
if [String, Hash, Array].include?(args.first.class)
conditions = @klass.send(:merge_conditions, args.size > 1 ? Array.wrap(args) : args.first)
else

0 comments on commit 5cd8818

Please sign in to comment.