Rails 3 ActionMailer and Wicked_PDF

前端 未结 3 1541
后悔当初
后悔当初 2020-12-08 15:21

I\'m trying to generate emails with rendered PDF attachements using ActionMailer and wicked_pdf.

On my site, I\'m using already both wicked_pdf and actionmailer se

3条回答
  •  感动是毒
    2020-12-08 15:48

    I used of Unixmonkey's solutions above, but then when I upgraded to rails 3.1.rc4 setting the @lookup_context instance variable no longer worked. Perhaps there's another way to achieve the same clearing of the lookup context, but for now, setting the attachment in the mail block works fine like so:

      def results_email(participant, program)
        mail(:to => participant.email,
             :subject => "my subject") do |format|
          format.text
          format.html
          format.pdf do
            attachments['trust_quotient_results.pdf'] = WickedPdf.new.pdf_from_string(
              render_to_string :pdf => "results",
                   :template => '/test_sessions/results.pdf.erb',
                   :layout => 'pdf.html')
          end
       end
      end
    

提交回复
热议问题