我試圖將current_employer.id傳遞給動作郵件程序。因此,我可以給屬於僱主的用戶發送電子郵件。將current_user.id傳遞給actionmailer
我的郵件看起來像這樣。
class ScheduleMailer < ActionMailer::Base
default to: Proc.new { Employee.where(:employer_id => current_employer.id
).pluck(:email) },
from: '[email protected]'
def schedule_post_reg(employ)
mail(:subject => "Your schedule has been posted.")
end
end
我得到這個錯誤
NameError (undefined local variable or method `current_employer' for #<ScheduleMailer:0x0000010cec0880>):
app/mailers/schedule_mailer.rb:3:in `block in <class:ScheduleMailer>'
app/mailers/schedule_mailer.rb:10:in `schedule_post_reg'
app/controllers/schedules_controller.rb:235:in `approve_shift'
如何通過不是的ActionMailer將不勝感激的current_employer.id任何建議。
在你的控制器'@employer = Employer.find_by_id(USER_ID) 僱主= @employer ScheduleMailer.schedule_post_reg控制器寫入somethigng(聘用, @employer).deliver' – Sontya 2015-02-10 14:16:50