I followed RailsCasts for PRAWN . Taking what has already been said and what I am trying to do in a similar way, I set the name of the attachment and then created a PDF.
InvoiceMailer:
def invoice_email(invoice) @invoice = invoice @user = @invoice.user attachments["#{@invoice.id}.pdf"] = InvoicePdf.new(@invoice, view_context).render mail(:to => @invoice.user.email, :subject => "Invoice # #{@invoice.id}") end
kobaltz
source share