-
-
Save geocodinglife/668ee96a3fe17eb55165bc4f4db5c48e to your computer and use it in GitHub Desktop.
send pdf attachment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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