method

destroy_all

Importance_2
v2.0.3 - Show latest stable - 0 notes - Class: ActiveRecord::Base
destroy_all(conditions = nil) public

Destroys the records matching conditions by instantiating each record and calling the 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.

Options

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.

Show source
Register or log in to add new notes.