I understand one could do something like Model.destroy_all(status: "inactive"). I wish my case were this simple, but I can't do it like that. I have an encrypted string column that maps to an array of integers via the attr_encrypted gem which makes this cumbersome.
Basically, I have an array like this: array = [object1, object2, object3, object4] where each object is model object.
I want to be able to do something like Model.destroy_all(array) or Model.delete_all(array), but I am unable to do this.
I even tried the following: Model.destroy_all(array.map(&:id)) and Model.delete_all(array.map(&:id)) and I couldn't successfully delete them.
I want to be as efficient as possible and I don't think array.map(&:destroy) or array.map(&:delete) would be efficient as I'd get N calls. Should I do that and wrap it in a transaction? Is there a better way?
Update: I figured it out and included an answer down below.
Model.destroy_all(id: array.map(&:id)). I believe it better optimized compared toModel.destroy(array).