mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Adding examples
This commit is contained in:
committed by
Mani Tadayon
parent
2b6845b1ef
commit
b39766fda5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user