voltrb

Delete entire voltrb store collection


store.widgets.clear does not seem to save into the Database. So I tried:

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

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


Solution

  • I need to add a .destroy_all (or make .clear do that), but haven't gotten around to it. The issue your seeing with .each is that its iterating through the array while deleting. For now you can do:

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

    I'll prioritize the destroy_all.