Reputation: 1086
Is it possible to have multiple pdf links on one page using wicked_pdf? I can't seem to find any information on this.
For example I have a daily sales report and a weekly sales report that I want to be accessible as a pdf download on the show page.
Controller
format.pdf do
render pdf: "#{@sales.name}",
template: 'trials/sales_day_report',
disposition: 'attachment'
end
format.pdf do
render pdf: "#{@sales.name}",
template: 'trials/sales_weekly_report',
disposition: 'attachment'
end
Show
<%= link_to 'Download Daily Report', sale_path(format: 'pdf') %>
<%= link_to 'Download Weekly Report', sale_path(format: 'pdf') %>
Upvotes: 0
Views: 440
Reputation: 356
You need yo pass an extra parameter whitin your links like this:
<%= link_to 'Download Daily Report', sale_path(format: 'pdf', sale_type: 'daily') %>
<%= link_to 'Download Weekly Report', sale_path(format: 'pdf', sale_type: 'weekly') %>
Then, interpolate that paramater in your pdf template route:
format.pdf do
render pdf: "#{@sales.name}",
template: "trials/sales_#{params[:sale_type]}_report",
disposition: 'attachment'
end
Upvotes: 1