module Billing class InvoiceMailer < ApplicationMailer def invoice_pdf @invoice = params[:invoice] @club = @invoice.club I18n.with_locale(I18n.locale) do prefix = t("mailers.invoice.attachment_prefix") attachments["#{prefix}-#{@invoice.number.parameterize}.pdf"] = { mime_type: "application/pdf", content: @invoice.pdf.download } mail( to: @club.billing_email, subject: t("mailers.invoice.subject", number: @invoice.display_number) ) end end end end