diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-12-27 19:22:18 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-12-27 19:22:18 +0530 |
commit | 5cd8818258cf7ce2c90667076d3f61f1c7ed548e (patch) | |
tree | a085e2fcfeee27017e0d33bd9e29589ab4e9b31c /activerecord | |
parent | 352cc7c94a19f596b3ecb5f1a2b9712b1519e978 (diff) | |
download | rails-5cd8818258cf7ce2c90667076d3f61f1c7ed548e.tar.gz rails-5cd8818258cf7ce2c90667076d3f61f1c7ed548e.tar.bz2 rails-5cd8818258cf7ce2c90667076d3f61f1c7ed548e.zip |
Make Model.destroy_all use new finders
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 0d3ae1ef3e..a3b123c463 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) - 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 diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index e52c7c3dc6..bec9a88297 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -88,6 +88,8 @@ module ActiveRecord 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 |