ruby on rails - Generating and linking to multiple prawn pdfs single action -
i'm generating pdf using prawn gem on show
action:
format.pdf pdf = procurementreportpdf.new @real_property_sale_project, current_user, view_context send_data pdf.render, filename: "procurementreport.pdf", type: "application/pdf", disposition: "inline" end
i access pdf in show view so:
<%= link_to '', "/real_property_sale_projects/#{@rpsp.id}.pdf", class: "fa fa-file-pdf-o right track-with-mixpanel", :data => { :event => "clicked bid export icon", tooltip: "export_bids" }, :title => "procurement report (pdf)", :target => "_blank" %>
i generate second report action i'm unsure of best way this? after generating report how go linking in view?
solved defining following method in controller:
def vendor_report @real_property_sale_project = realpropertysaleproject.find params[:project_id] respond_to |format| format.pdf vendor_report = vendorreportpdf.new @real_property_sale_project, current_user, view_context send_data vendor_report.render, filename: "vendor_report.pdf", type: "application/pdf", disposition: "inline" end end end
added route:
get 'vendor_report', to: 'real_property_sale_projects#vendor_report', as: 'vendor_report'
and added link in show
view:
<%= link_to 'vendor report', vendor_report_path(project_id: @rpsp.id, format: 'pdf') %>