我已经找了很多年了,但我似乎仍然无法弄清楚,
我目前正在使用,prawn gem并且我希望能够将 a 附加pdf到email我的invoice controllers create action. 我目前可以从我的invoices/show页面链接到生成的 pdf http://localhost:3000/invoices/297.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
Run Code Online (Sandbox Code Playgroud)
和我的 InvoicesController 创建操作
{...}
respond_to do |format|
if @invoice.save
InvoiceMailer.invoice_email(@invoice.user).deliver
format.html { redirect_to invoice_url(@invoice, back_path:
{...}
Run Code Online (Sandbox Code Playgroud)
如何将我的发票作为附件添加到此邮件中?在发送发票之前,我是否需要将发票存放在某个地方?