所以,我有其中recruiter
岗位工作(招聘has_many jobs
,所有协会都设置正确)Rails应用程序和users
能够点击一个应用按钮,发送使用Action梅勒电子邮件到该特定工作的招聘人员。发送电子邮件在Rails应用程序
User
和Recruiter
是由Devise创建的两个独立模型。
乔布斯被rails g scaffold Job .....
产生的继承人是我到目前为止有:
ApplyMailer.rb:
class ApplyMailer < ApplicationMailer
def new_apply(job)
@user = current_user
@job = job
mail to: @job.recruiter.email,
subject: "Someone whats to appy for #{@job.title}"
end
end
乔布斯#显示视图:
<%= button_to(apply_path, class:"btn btn-info") do %>
Apply
<% end %>
Jobs_controller.rb :
def sendemail
@job = Job.find(params[:id])
ApplyMailer.new_apply(@job).deliver_now
end
的routes.rb
post '/apply' => 'jobs#sendemail'
首先我不知道如果我这样做是为了什么,我试图达到的正确方法。我想要做的是:
因此,该按钮位于jobs#show
页面上,它应该将该job
作为参数并向associated recruiter
发送电子邮件。 current_user (User model)
将是试图申请这项工作的用户,所以在电子邮件视图中会显示用户的名字(请查看下面的内容)。
new_apply.html.erb:
<div class="">
<h2><%= @user.profile.name %> want to apply for the job</h2>
</div>
的问题是,按下按钮后,怎么可能一个电子邮件有关job
邮递方式送交recruiter
。该电子邮件需要包含current_user
名称和电子邮件。以上是我所尝试的,但没有电子邮件发送。
感谢
请提出这样的问题,而不是告诉我们你做了什么! –
您需要传入用户,邮件程序不知道什么是'current_user'是 –
问题是什么? –