diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-02 15:50:34 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-02 15:50:34 -0800 |
commit | b0fc912f1b829391760b50107dad365fa87c744f (patch) | |
tree | 6a755ad82e410e331b1d7b06f1ef7682e5f8eaef | |
parent | 8c9b5e413ff9bab8607377223dd42a0ff4375405 (diff) | |
download | rails-b0fc912f1b829391760b50107dad365fa87c744f.tar.gz rails-b0fc912f1b829391760b50107dad365fa87c744f.tar.bz2 rails-b0fc912f1b829391760b50107dad365fa87c744f.zip |
avoid deprecate api
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 646bf8f4be..3009bb70c1 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -271,7 +271,14 @@ module ActiveRecord # 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) - conditions ? where(conditions).delete_all : arel.delete.tap { reset } + if conditions + where(conditions).delete_all + else + statement = arel.compile_delete + affected = @klass.connection.delete statement.to_sql + reset + affected + end end # Deletes the row with a primary key matching the +id+ argument, using a |