【发布时间】:2016-04-08 03:28:58
【问题描述】:
我一直在寻找,但我似乎仍然无法弄清楚,
我目前正在使用prawn gem,我希望能够在我的invoice controllers create action 中将pdf 附加到email。我目前能够通过http://localhost:3000/invoices/297.pdf 链接到我的invoices/show 页面生成的pdf,但我不知道如何将此pdf 附加到电子邮件中。
目前我没有将生成的 PDF 存储在任何地方,我的邮件看起来像这样
邮递员
class InvoiceMailer < ActionMailer::Base
default :from => "notifications@example.com"
def invoice_email(user)
@user = user
mail(:to => user.email, :subject => "Invoice Recieved")
end
end
我的 InvoicesController 创建操作
{...}
respond_to do |format|
if @invoice.save
InvoiceMailer.invoice_email(@invoice.user).deliver
format.html { redirect_to invoice_url(@invoice, back_path:
{...}
如何将我的发票作为附件添加到此邮件中?我是否需要先将发票存储在某个地方才能发送?
【问题讨论】:
标签: ruby-on-rails actionmailer prawn