Rails3 - wicked_pdf gem, footer issue when calling from action mailer model

ⅰ亾dé卋堺 提交于 2019-12-03 20:33:45
Unixmonkey

This looks to be related to the problem in this question:

Rails 3 ActionMailer and Wicked_PDF

Where the mailer doesn't like it when you call render.

Try wrapping your attachment setting in a respond_to block like so:

mail(:subject => 'Your pdf', :to => user.email) do |format|
  format.text
  format.pdf do
    attachments['pdf.pdf'] = WickedPdf.new.pdf_from_string(
      render_to_string(
        :pdf      => "pdf.pdf",
        :template => 'pdf/pdf.html.erb',
        :layout   => 'pdfs/pdf', 
        :footer   => {
          :html => {
            :template => 'pdf/pdf_footer.html.erb',
            :layout   => 'pdfs/pdf'
          },
          :spacing => -65
        }                 
      )
  end
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!