Skip to content

Instantly share code, notes, and snippets.

@Nosfheratu
Created January 18, 2019 04:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Nosfheratu/d121739953db6c530206de2e52cf0404 to your computer and use it in GitHub Desktop.
Save Nosfheratu/d121739953db6c530206de2e52cf0404 to your computer and use it in GitHub Desktop.
send pdf attachment
class MyMailer < ApplicationMailer
def send_invoice user, invoice
@user = user
@invoice = invoice
invoice_attachment = WickedPdf.new.pdf_from_string(render_to_string(pdf: "invoice", template: 'payments/charges/invoice.pdf.erb'))
attachments["I#{sprintf('%06d', @invoice.id)}.pdf"] = invoice_attachment
mail(to: @user.email,
subject: "Your invoice", template_path: 'users_mailer')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment