Flowdock
method

delete_all

Importance_2
delete_all(conditions = nil) public

Deletes the records matching conditions without instantiating the records first, and hence not calling the destroy method and invoking callbacks. This is a single SQL query, much more efficient than destroy_all.

Attributes

  • conditions - Conditions are specified the same way as with find method.

Example

  Post.delete_all "person_id = 5 AND (category = 'Something' OR category = 'Else')"

This deletes the affected posts all at once with a single DELETE query. If you need to destroy dependent associations or call your before_ or after_destroy callbacks, use the destroy_all method instead.

Show source
Register or log in to add new notes.