【发布时间】:2016-04-29 20:16:48
【问题描述】:
我正在一个具有这些关系的工作委员会工作,一个用户可以申请许多工作,并且工作有许多申请者(用户)。一家公司有很多工作。
用户:
has_many :applications
has_many :jobs, :through => :applications, :uniq => true
工作
has_many :applications
has_many :users, :through => :applications
应用
belongs_to :user
belongs_to :job
公司
has_many :jobs, dependent: :destroy
我想实现一个功能,在用户申请工作时向公司发送电子邮件。
这是我的邮件:
class NotificationMailer < ActionMailer::Base
default from: "email@gmail.com"
def job_application(company)
@company = company
@job = job
@applications = @job.applications
company = @job.application.company
mail(to: @company.email, subject: 'Ha recibido una postulacion')
end
end
应用程序.rb
after_create :send_email
def send_email
NotificationMailer.job_application(self.company).deliver
end
很明显我有一些错误,在用户申请工作后,我必须更改或添加哪些内容才能向公司发送电子邮件?谢谢。
【问题讨论】:
标签: ruby-on-rails ruby email