【发布时间】:2017-06-14 06:43:52
【问题描述】:
我正在尝试使用我在 development.rb 文件中完成的配置的 smtp 方法发送邮件,这里是
Rails.application.configure do
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: 'angad1@gmail.com',
password: xxxxxxxx,
authentication: 'plain',
enable_starttls_auto: true
}
这是位于 mailers 文件夹下的 UserMailer,这里我从控制器获取参数值,并将参数分配给变量,以便视图可以使用它 UserMailer.rb
class UserMailer < ApplicationMailer
default from: 'angad1@gmail.com'
layout 'mailer'
def conference_result(email,proposal,acknowledgement,positive,negative,chart)
@email = email
@proposal = proposal
@acknowledgement = acknowledgement
@positive = positive
@negative = negative
@chart = chart
mail(to: @email , subject: 'Result for Your conference meeting' , content_type: "text/html")
end
end
这是我想通过邮件传递的内容, mailer.html.erb
<body>
<%= yield %>
<h3 class="text-center" id="proposalhead">Proposal</h3>
<div style="border:1px solid rgba(0,0,0,0.3);background-color: rgba(255,255,255,0.1);margin-top:10px;margin-bottom:10px;" class="text-center">
<%= @proposal %>
</div>
<h3 class="text-center hidden" id ="acknowledgementhead">Acknowledgement</h3>
<div style="border:1px solid rgba(0,0,0,0.3);background-color: rgba(255,255,255,0.1);margin-top:20px;margin-bottom:20px;" id ="Acknowledgement" class="text-center">
<%= @acknowledgement %>
</div>
<h3 class="text-center hidden" id ="positivehead">Positive</h3>
<div style="border:1px solid rgba(0,0,0,0.3);background-color: rgba(255,255,255,0.1);margin-top:10px;margin-bottom:10px;" id ="Positive" class="text-center">
<%= @positive %>
</div>
<h3 class="text-center hidden" id ="negativehead">Negative</h3>
<div style="border:1px solid rgba(0,0,0,0.3);background-color: rgba(255,255,255,0.1);margin-top:10px;margin-bottom:20px" id = "Negative" class="text-center">
<%= @negative %>
</div>
<div id="chart_div" style="width:100%;margin-bottom: 15px;margin-top:15px;" class="text-center">
<%= @chart %>
</div>
</body>
当我尝试发送邮件时,它显示以下错误
ActionView::MissingTemplate(缺少带有“mailer”的模板user_mailer/conference_result。搜索到:*“user_mailer”)
请帮帮我,我是 ruby 新手。
【问题讨论】:
-
user_mailerforlder 中是否有 Conference_result 电子邮件模板?
标签: ruby-on-rails ruby