class A < ActiveRecord::Base
def self.a
A.first.touch
delay(run_at: Proc.new{ 10.seconds.from_now }).a
log.info 'Added job to run at ' + 10.seconds.from_now.to_s
end
def self.log
@log ||= Logger.new 'dj.log'
end
end
为什么我在工作日志中看到这个:
Added job to run at 2013-04-26 01:04:53 UTC
Added job to run at 2013-04-26 01:04:53 UTC
Added job to run at 2013-04-26 01:04:54 UTC
Added job to run at 2013-04-26 01:04:54 UTC
Added job to run at 2013-04-26 01:04:55 UTC
注意:不分开 10 秒。