Permalink
Browse files

Adding examples

  • Loading branch information...
1 parent bdf83b7 commit 4da0157aaffef6063d5ad2984c4a4e472f15f0d5 @reu reu committed Feb 21, 2011
Showing with 2 additions and 0 deletions.
  1. +2 −0 activerecord/lib/active_record/relation.rb
View
2 activerecord/lib/active_record/relation.rb
@@ -249,6 +249,7 @@ def update(id, attributes)
#
# 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 @@ def destroy(id)
#
# 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

0 comments on commit 4da0157

Please sign in to comment.