Graham Jones
Graham Jones

Reputation: 58

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?

Upvotes: 3

Views: 69

Answers (1)

Ryan
Ryan

Reputation: 956

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.

Upvotes: 5

Related Questions