Search code examples
ruby-on-railsrubywicked-pdf

Ruby on Rails Wicked PDF Template Missing Error


I am currently using rails 7 with wicked pdf . wicked pdf is throwing me an missing template error even if I have template file at exact place? what am i doing wrong?

  def show
   respond_to do |format|
    format.html
    format.pdf do
     render pdf: "file_name", template: "stocks/pdf.html.erb"
    end
   end
 end

what am i doing wrong ? I am using tailwindcss with jsbuild if that matters.


Solution

  • in case your template is stocks/pdf.html.erb, your render should be as following:

    format.pdf do
      render pdf: "file_name", template: "stocks/pdf", formats: [:html]
    end
    

    Let me know if this works for you.

    Cheers