我正在尝试使用 ActionMailer 创建电子邮件。发票电子邮件已发送。
但是,发送电子邮件后,我在屏幕上收到此错误:
ActionView::MissingTemplate at /invoices/sendinvoice
Missing template invoices/sendinvoice, application/sendinvoice
这是在我的 invoices_controller.rb
def sendinvoice
@invoice = Invoice.find(params[:invoice_id])
InvoiceMailer.invoice_email(@invoice).deliver
end
这是在 mailers/invoice_mailer.rb
class InvoiceMailer < ActionMailer::Base
default from: "ndeavor@ameipro.com"
def invoice_email(invoice)
@invoice = invoice
mail(:to => @invoice.workorder.contact.email, :subject => "New Invoice from " + @invoice.tenant.name )
end
end
这是在views/invoice_email.html.erb
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
</head>
<body>
<h2>Invoice</h2>
</body>
</html>
这是 invoices/show.html.erb 中的一个按钮
<%= link_to 'Send Invoice', invoices_sendinvoice_path(:invoice_id => @invoice), :class => 'btn btn-primary' %>
这是在路线中:
get "invoices/sendinvoice"
谢谢您的帮助!