Flowdock
method

destroy_by

Importance_1
v6.0.0 - Show latest stable - 0 notes - 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)
Show source
Register or log in to add new notes.