Delete entire collection of voltrb stores

store.widgets.clear

doesn't seem to be saved to the database. So I tried:

store.widgets.each do |i|
  i.destroy
end

      

And this only destroys half of the records in the database. Any suggestions on how I can delete the entire store collection?

+3


source to share


1 answer


I need to add .destroy_all (or do .clear) but haven't gotten to it. The problem you see with .each is that it iterates through the array on deletion. For now, you can do:

store.widgets.reverse.each(&:destroy)



I will prioritize destroy_all.

+5


source







All Articles