# Taking advantage of template generation from within a model?

**URL:** <https://www.ruby-forum.com/t/taking-advantage-of-template-generation-from-within-a-model/151401>\
**Category:** Rails\
**Created:** [October 21, 2008, 1:06am UTC](https://www.ruby-forum.com/t/taking-advantage-of-template-generation-from-within-a-model/151401 "2008-10-21T01:06:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [October 21, 2008, 1:06am UTC](https://www.ruby-forum.com/t/taking-advantage-of-template-generation-from-within-a-model/151401/1 "2008-10-21T01:06:36Z")

</div>

All,

I have a controller action/view pair that successfully generates a PDF  
using Prawnto.

I like the idea of the view specifying the details of the PDF generation  
in a view file (x.pdf.prawn).

However, I would like to be able to generate a PDF and instead of  
rendering it to a view, just generate it and save it to a file. I’m  
doing this inside of a model method.

Obviously, I can pull the PDF generation into a module and call it from  
both places, but I was wondering if there’s any clean way to take  
advantage of the template that I already have without going through too  
many gyrations.

Thanks,  
Wes
