Rails: Send a shrimp email to an email sent by ActionMailer?

I have an ecommerce app. I use shrimp to generate PDF order orders. I use the standard shrimp setting. In views / admin / orders, I have a file called show.pdf.prawn. When the seller views the order in his admin section, he clicks the link that opens the PDF version of the order submission / display. All of this works great.

Now the tricky part. When the order is completed, I will send an email to the seller. What I would like to do is attach the pdf version of the purchase orders for this letter. Is it possible to do this? The email attachment documentation is pretty limited, and I could not find the resources that go through the workflow that I am describing.

Any guidance is appreciated.

+3
source share
2 answers

Sending an application via email is pretty easy using ActionMailer:

class InvoiceMailer < ActionMailer::Base

  def email_with_attachment(pdf_invoice)
    .
    .
    .

    attachment "application/pdf" do |a|
      a.filename = "some_invoice.pdf"
      a.body = pdf_invoice
    end
  end

end

, , pdf prawnto ( prawnto) - , .

+2

, , pdf , , . :

PDF ?

0

Source: https://habr.com/ru/post/1756689/


All Articles