How can I setup a user-defined template in prawn - prawnto?

804 Views Asked by At

I'm using prawn with prawnto in a rails 3 application to generate some pdf's. I have created a pdf.prawn template for a specific controller's action, and it is working fine.

I have the following code in my 'document' controller, as suggested by prawnto documentation:

respond_with(@document) do |format|
      format.html
      format.pdf { render :layout => false } # Add this line
end

What I would like to achieve is to allow each user of the app to select different templates, and accordingly, be able to render the corresponding XXXX.pdf,prawn templates.

How can I define dynamically the prawn template name to be rendered, based on a variable, instead of the default show.pdf.prawn template?

I have been looking for a couple of days for this feature, but have not found anything similar.

I am willing to drop prawnto and use plain prawn if this could solve this issue.

Thank you very much for your time!

Alex

1

There are 1 best solutions below

0
On BEST ANSWER

I guess you can use,

render :template => "path/to/xxx.pdf.prawn", :layout => false