method
destroy_by
v7.1.3.4 -
Show latest stable
- Class:
ActiveRecord::Relation
destroy_by(*args)public
Finds and destroys all records matching the specified conditions. This is short-hand for relation.where(condition).destroy_all. Returns the collection of objects that were destroyed.
If no record is found, returns empty array.
Person.destroy_by(id: 13) Person.destroy_by(name: 'Spartacus', rating: 4) Person.destroy_by("published_at < ?", 2.weeks.ago)