我是Delayed Jobs的新手,我不确定我是否正确这样做。
工人
class BillingFailedEmailWorker < BaseWorker
attr_accessor :car
def initialize(car)
@car = car
end
def billing_failed_for_subscriptions
StripeMailer::billing_failed_for_subscriptions(car.owner.email).deliver
end
def perform
self.class.new(car).delay(
run_at: DateTime.now + 1.week,
queue: "Failed Subscription"
).billing_failed_for_subscriptions
end
end
邮件程序
class StripeMailer < ActionMailer::Base
default from: Settings.default_from_email
def billing_failed_for_subscriptions(email)
mail to: email, subject: 'Autobrain Subscription Renewal Failed'
end
end
billing_failed_for_subscriptions
显然也对应于正确的邮件程序视图。
我的问题是当我运行BillingFailedEmailWorker.new(Car.last).perform
时,我看到命令在Delayed::Backend::ActiveRecord::Job
中正确执行,但是当我运行Delayed::Backend::ActiveRecord::Job.last
或Delayed::Job.last
时,我看不到我刚才的工作创建。
这可能是我的Rails环境正在开发中还是我缺少的东西?
答案 0 :(得分:0)
而不是使用
使用