我的控制器中有一个方法,我需要在延迟作业方法中执行:
这是我的order controller action
:
class OrdersController < ApplicationController
def create
#code here
order = Order.first
Order.delay(queue: "order", priority: 1, run_at: 2.minutes.from_now).expire_order(order)
end
def template_expired_order(order)
#code here
end
end
这是我的order model:
class Order
include Mongoid::Document
include Mongoid::Timestamps::Created
.
.
.
#delayed jobs method
def self.expire_order(order)
#code here
end
end
我想在执行或触发或启动方法template_expired_order(order)
时执行控制器方法。self.expire_order(order)
我该怎么做?
非常感谢你!