0
我是actionmailer的新手,看起來無法獲得ActionMailer的正常工作和路由,不知道我是否正確地進行了操作,大多數教程僅顯示如何生成通用用戶首次創建帳戶後發送電子郵件。Rails 4 ActionMailer從表單創建併發送電子郵件
我想要做的是允許用戶通過表單生成一封電子郵件,併發送帶有鏈接到視圖的電子郵件給他們的客戶查看發票。
我現在的錯誤是由於一些路由問題,但奇怪的是,它看起來在我的控制器,而不是郵件控制器郵件模板是我的假設... Missing template invoices/send_invoice_email, application/send_invoice_email
這裏是我的形式的用戶將使用建立電子郵件。
<%= bootstrap_form_tag url: '/send_invoice' do |l| %>
<%= l.hidden_field :invoice, value: @quote.id %>
<div class="input-group margin-bottom-20">
<span class="input-group-addon" id="from"><i class="fa fa-envelope"> </i></span>
<%= l.text_field :from, hide_label: true, value: current_user.email %>
</div>
<div class="input-group margin-bottom-20">
<span class="input-group-addon" id="to"><i class="fa fa-user"> </i></span>
<%= l.text_field :to, hide_label: true, value: @quote.client.contacts.first.email %>
</div>
<div class="input-group margin-bottom-20">
<span class="input-group-addon" id="cc"><i class="fa fa-users"> </i></span>
<%= l.text_field :cc, hide_label: true, placeholder: "cc:" %>
</div>
<div class="input-group margin-bottom-20">
<span class="input-group-addon" id="bcc"><i class="fa fa-users"> </i></span>
<%= l.text_field :bcc, hide_label: true, placeholder: "bcc:" %>
</div>
<div class="input-group margin-bottom-20">
<span class="input-group-addon" id="subject"> <i class="fa fa-bullhorn"></i></span>
<%= l.text_field :subject, hide_label: true, placeholder: "Subject" %>
</div>
<div class="input-group margin-bottom-20">
<span class="input-group-addon" id="message"> <i class="fa fa-comment"></i></span>
<%= l.text_area :message, hide_label: true, placeholder: "Message", rows:"5" %>
</div>
<%= l.submit "Send", class:'btn-u btn-u-blue btn-block' %>
<% end %>
在我的發票控制器(這只是一個節目控制器,在報價模型創建行情)我的控制器方法
def send_invoice_email
quote = Quote.find(params[:invoice])
InvoiceMailer.send_invoice_email(quote, params)
end
這裏是我的發票郵件的方法
def send_invoice_email(quote, params)
@quote = quote
mail(
to: current_user.email,
from: params[:from],
content_type: "text/html",
body: params[:body],
content_type: "text/html",
subject: params[:subject],
content_type: "text/html"
)
end