Question

I am using the prawn gem in Rails to generate a PDF. Currently I am using disposition: "inline" to render the PDF in the browser (and in my view: <%= link_to "PDF", product_path(@product, format: "pdf") %>. Is there any way that I can have multiple dispositions so that in my view I could have one link that renders the PDF in the browser and a separate link that will automatically download the PDF?

Était-ce utile?

La solution

You can insert link as you've specified to render the .pdf, and call to a specific action of a controller, in which you have to send the .pdf as a file, for example with #send_file method:

send_file '/path/to.pdf', type: 'document/pdf'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top