我正在尝试向yelp克隆添加邮件功能,以在用户创建的餐厅位置留下其他用途的评论时通知用户。当我尝试在Rails控制台中强制发送电子邮件时,收到以下错误消息:ActionView::MissingTemplate
这是针对内置了邮件程序的Ruby Rails5。我试图将Doctype模板添加到我的邮件程序代码中,但这种方式仍然会出错。
这是我的NotificationMailer.rb:
class NotificationMailer < ApplicationMailer
default from: "no-reply@nomsterapp.com"
def comment_added
mail(to: "*****@yahoo.com",
subject: "A comment has been added to your place")
end
end
这是ApplicationMailer.rb:
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
class UserMailer < ApplicationMailer
end
这是comment_added.html.erb:
<p>Hey There!</p>
<p>
Congrats! <b>A comment has been added on Nomster</b>
</p>
Aloha,<br />
Eric
I should be able to input in the console NotificationMailer.comment_added.deliver and it send me an email. But the console kicks this error back to me:
NotificationMailer#comment_added: processed outbound mail in 574.8ms
Traceback (most recent call last):
2: from (irb):6
1: from app/mailers/notification_mailer.rb:14:in `comment_added'
ActionView::MissingTemplate (Missing template notification_mailer/comment_added with "mailer". Searched in:)
* "notification_mailer"
答案 0 :(得分:0)
我猜问题出在comment_added.html.rb
的名字下,应该是comment_added.html.erb
另外,您还应确保它在此目录下app / views / notification_mailer /