pdf
をattachment
として電子メールに送信しようとしています。エラーが表示されます。wicked-pdfから生成された電子メールにpdf添付ファイルを送信できません。
ctionView::MissingTemplate at /invoises/BRUqWOeEVNSN6GCwxQqLGg%253D%253D/send_invoice_email Missing template invoises/#{invoise.id}/show_pdf_invoice.pdf.erb with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :m
私はmailer
でcontroller
def send_invoice_email
CompanyMailer.invoice(@invoise.id).deliver
redirect_to invoices_path, notice: 'Invoice Sent successfully.'
end
ロジックでpdf
view
html
からメソッドを生成するために
wicked_pdf
gem.tryingを使用しています:
def invoice(invoice)
invoice = Invoice.find(invoice)
attachments["invoice.pdf"] = WickedPdf.new.pdf_from_string(
render_to_string(:pdf => "invoice",:template => 'invoices/#{invoice.id}/show_pdf_invoice.pdf.erb')
)
mail(to: "[email protected]", subject: 'Your todo PDF is attached')
end
を
controller
def show_pdf_invoice
respond_to do |format|
format.html { render :layout => false }
format.pdf do
render pdf: "show_pdf_invoice"
#render :pdf => "pdf"#, :layout => 'pdf.html.erb'
end
end
end
方法及びinvoices/show_pdf_invoice.pdf.erb
<h1>this is pdf invoice.<h1>
およびcompany_mailer/invoice.html.erb
please find attached pdf.
invoice /#{invoice.id} /show_pdf_invoice.pdf.erb "に変更すると、文字列補間の最も外側の引用符として二重引用符が使用されます。 – jvnill
私はその行を変更しました。それでも同じエラーです。 – John
'render_to_string(テンプレート: '請求書/ show_pdf_invoice.pdf.erb')に変更 – jvnill