Rails – Delete all Records that Meet a Condition

I think it is better to use destroy instead of delete

because destroy will delete current object record from db and also its
associated children record from db (https://stackoverflow.com/a/22757656/5452072)

Also delete will skip callbacks, but destroy doesn’t.

Manager.where(:manager_level => 5).destroy_all

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)