I am running Rails 4.2.0 with Ruby 2.0.0. I iterate over the model Production.alland call production.finish!in the .each loop. My end! the method, in the end, removes itself using self.destroy. But each undefined record will be executed twice in a single loop.
def finish!
self.progress = true
self.save
if DeliveredProduction.find_by_production_id(self.id)
else
DeliveredProduction.create!(:production_id => self.id)
end
self.destroy
end
Is there a bug in Rails 4.2.0 or Ruby 2.2.0p0? Only after 1-2 days is a single execution performed. This code will be executed by crontab. I also update all Production in an iteration with progress = true, so that later crontabs will not be able to access these objects. My debug log says that the second execution of the same Production occurs after the same time (one second) after a few seconds.
source
share