I'm trying to figure out if I'm able to use delayed_job
. I would need the ability to add jobs to the queue within a delayed_job
perform
method. Is this possible?
According to my test, they can:
model Machine
:
class Machine < ActiveRecord::Base
def perform
Delayed::Job.enqueue Secondary.create!
end
end
model Secondary
:
class Secondary < ActiveRecord::Base
def perform
logger.info("Inside secondary's perform method (WIN)")
Proof.create!
end
end
from the console:
Delayed::Job.enqueue Machine.create!
This ends up creating an instance of Proof
and logs "Inside secondary's...".
我简单的测试呼叫send_later
通过调用的方法send_later
表明,NO,它不会工作。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.