4 つのアクションを持つメーラー クラスがあります。バックグラウンドですべてのメーラーを処理するために DelayedJob を使用しています。1つを除いて、すべて問題なく動作しています。ワーカーから得られるエラーは次のとおりです。
Class#exit failed with ArgumentError: wrong number of arguments (3 for 0..1)
ActiveRecord::Relation オブジェクトをメーラー メソッドに渡す際の一般的な問題は理解していますが、ここではそれを行いません。.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
これが役立つ情報であることを願っています、ありがとう。