if params[:invoice_id].presence
@invoice = Invoice.find(params[:invoice_id])
attachments['invoice.pdf'] = WickedPdf.new.pdf_from_string(
render_to_string(
template: 'invoices/service',
locals: { current_user: }
)
)
end
I have attached a PDF from wickedpdf but after sending the attachment it comes as blank white page.
I am trying to send Attachment in Ruby on Rails with ActionMailer with PDF as an attachment.
By looking at the example in the Wicked PDF documentation it looks like you are missing the
layoutoption in therender_to_stringmethod.I suggest to do something like this: