我有一个包含四个动作的邮件类。我正在使用 DelayedJob 在后台处理我的所有邮件。除了一个之外,它们都完美无缺地工作。我从工人那里得到的错误是:
Class#exit failed with ArgumentError: wrong number of arguments (3 for 0..1)
我了解将 ActiveRecord::Relation 对象传递给 mailer 方法的常见问题,我在这里不这样做。如果我取消 .delay() 调用并使用旧的 .deliver() 方法,它会起作用并将其发送出去,尽管显然不在后台,所以不理想。任何人都可以看到我可能做错并忽略的事情吗?
我正在使用 DelayedJob-3.0.5 和 Rails 3.2.11。
class AdminMailer < ActionMailer::Base
default :from => "x@x.com"
def exit(customer, user, exit_reason)
@customer = customer
@user = user
@exit_reason = exit_reason
mail(to: "y@y.com", subject: "#{customer.business_name} canceled for this reason")
end
end
我正在从控制器调用邮件程序:
class ReportsController < ApplicationController
def exit_reason
ct = CustomerTracking.where(customer_id: params[:customer_id]).first_or_create
if ct.update_column(:exit_reason, params[:customer_tracking][:exit_reason]) &&
ct.update_column(:notes, "#{ct.notes} Exit Detail: #{params[:customer_tracking][:exit_detail]}")
flash.now[:success] = "Thank you for your answer."
else
flash.now[:error] = "Something went wrong!"
end
if params[:customer_tracking][:exit_detail].present?
exit_detail = params[:customer_tracking][:exit_detail]
customer = Customer.find(params[:customer_id])
AdminMailer.delay.exit(customer, customer.user, exit_detail)
end
end
end
希望这是足够的信息来帮助,谢谢。