method
destroy_all
v2.2.1 -
Show latest stable
- Class:
ActiveRecord::Base
destroy_all(conditions = nil)public
Destroys the records matching conditions by instantiating each record and calling their destroy method. This means at least 2*N database queries to destroy N records, so avoid destroy_all if you are deleting many records. If you want to simply delete records without worrying about dependent associations or callbacks, use the much faster delete_all method instead.
Parameters
- conditions - Conditions are specified the same way as with find method.
Example
Person.destroy_all("last_login < '2004-04-04'")
This loads and destroys each person one by one, including its dependent associations and before_ and after_destroy callbacks.
conditions can be anything that find also accepts:
Person.destroy_all(:last_login => 6.hours.ago)