Im just a bit curious as to what would happen in this scenario
(My setup is a MongoDB, Ruby on Rails via MongoID)
Models.all.each do |model|
model.destroy #delete the record
newmodel = model.new #make a new record
newmodel.someinfo = info #fill it with some info
newmodel.save #save it
end
If we destroy the records while looping through and make a new one.
Would we loop through forever (because we're deleting the old one and adding a new one)
What I mean to ask is perhaps would we loop through the new records that we would have added (on the line that says #save it
)
If not how would we code it to get that desired effect (loop through twice?) - Say I wanted an infinitely processing rake task?