Skip to content

Commit

Permalink
Make Model.destroy_all use new finders
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Dec 27, 2009
1 parent 352cc7c commit 5cd8818
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/base.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ def update_all(updates, conditions = nil, options = {})
# Person.destroy_all("last_login < '2004-04-04'") # Person.destroy_all("last_login < '2004-04-04'")
# Person.destroy_all(:status => "inactive") # Person.destroy_all(:status => "inactive")
def destroy_all(conditions = nil) def destroy_all(conditions = nil)
find(:all, :conditions => conditions).each { |object| object.destroy } where(conditions).each {|object| object.destroy }
end end


# Deletes the records matching +conditions+ without instantiating the records first, and hence not # Deletes the records matching +conditions+ without instantiating the records first, and hence not
Expand Down
2 changes: 2 additions & 0 deletions activerecord/lib/active_record/relation.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def joins(join, join_type = nil)
end end


def where(*args) def where(*args)
return create_new_relation if args.blank?

if [String, Hash, Array].include?(args.first.class) if [String, Hash, Array].include?(args.first.class)
conditions = @klass.send(:merge_conditions, args.size > 1 ? Array.wrap(args) : args.first) conditions = @klass.send(:merge_conditions, args.size > 1 ? Array.wrap(args) : args.first)
else else
Expand Down

0 comments on commit 5cd8818

Please sign in to comment.