Reputation: 63
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.
Upvotes: 1
Views: 2074
Reputation: 660
In my case, it worked only if I do:
<%= link_to "File", data_path(data, format: :pdf) %>
in orders_controller:
def data
format.pdf do
render pdf: "file_name", template: "orders/data", formats: [:html]
end
end
The file is in "orders/data.html.erb" path
Upvotes: 0
Reputation: 1226
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
Upvotes: 8