diff options
author | Rodrigo Navarro <rnavarro1@gmail.com> | 2011-02-20 22:03:29 -0300 |
---|---|---|
committer | Rodrigo Navarro <rnavarro1@gmail.com> | 2011-02-20 22:03:29 -0300 |
commit | 4da0157aaffef6063d5ad2984c4a4e472f15f0d5 (patch) | |
tree | e8221bb1bb69b16948af3852d47623f6d324a73a | |
parent | bdf83b7dc357baf7b380fed53508b850af9b6600 (diff) | |
download | rails-4da0157aaffef6063d5ad2984c4a4e472f15f0d5.tar.gz rails-4da0157aaffef6063d5ad2984c4a4e472f15f0d5.tar.bz2 rails-4da0157aaffef6063d5ad2984c4a4e472f15f0d5.zip |
Adding examples
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index cb684c1109..948f33f24e 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -249,6 +249,7 @@ module ActiveRecord # # Person.destroy_all("last_login < '2004-04-04'") # Person.destroy_all(:status => "inactive") + # Person.where(:age => 0..18).destroy_all def destroy_all(conditions = nil) if conditions where(conditions).destroy_all @@ -298,6 +299,7 @@ module ActiveRecord # # Post.delete_all("person_id = 5 AND (category = 'Something' OR category = 'Else')") # Post.delete_all(["person_id = ? AND (category = ? OR category = ?)", 5, 'Something', 'Else']) + # Post.where(:person_id => 5).where(:category => ['Something', 'Else']).delete_all # # Both calls delete the affected posts all at once with a single DELETE statement. # If you need to destroy dependent associations or call your <tt>before_*</tt> or |