ruby on rails - Running a cron job at different times for each job -


i building application in rails allows users post products sale set duration of time. each product has different 'end_time' in want run method sets updates product status 'dead'.
i've been reading on wheneverize gem, far can tell use doing recurring task every minute, hour, day, etc... ideas on how go running cron job run @ each product's specific 'end_time'?

for example along lines of:

live_products = product.where('status = ?', 'live')  live_products.each |product|  at: product.end_time    product.status = 'dead'    product.save  end end  

cronjob, every minute, checking need transaction dead.

product.turn_dead.update_all status: :dead     #product.rb scope :live, -> {where status: :live} scope :out_of_time, -> {where "end_time <= ?", time.now} scope :turn_dead, ->{ live.out_of_time } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -