# Serving autogenerated files to users

**URL:** <https://www.ruby-forum.com/t/serving-autogenerated-files-to-users/72048>\
**Category:** Rails\
**Created:** [October 13, 2006, 9:38pm UTC](https://www.ruby-forum.com/t/serving-autogenerated-files-to-users/72048 "2006-10-13T21:38:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stewbawka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@stewbawka](https://www.ruby-forum.com/u/stewbawka)\
**Post date:** [October 13, 2006, 9:38pm UTC](https://www.ruby-forum.com/t/serving-autogenerated-files-to-users/72048/1 "2006-10-13T21:38:52Z")

</div>

hi everybody,

my rails app generates a pdf specially made for a user after they  
finish filling out a set of online forms. i used pdf-writer to generate  
the pdf on the fly which works quite nicely.

my question:  
where should i generate the files to if i want the user to be able to  
download them after they generate? anywhere in the public folder? also,  
what is the ‘default’ path? public? so if make a hyperlink that has  
href="/pdfs/cust1.pdf" would that point to RAILS\_ROOT +  
‘/public/pdfs/cust1.pdf’ ???

anything else i need to look out for? also, i don’t plan on keeping  
these pdfs on the server forever… whats a good way to check if they’re  
stale and delete them if necessary? i think we are hosting this  
ourselves so it could be a crontab.

thanks in advance,

Stuart (the other stuart)

---

<div class="post-metadata">

**Author:** ![stewbawka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@stewbawka](https://www.ruby-forum.com/u/stewbawka)\
**Post date:** [October 13, 2006, 9:55pm UTC](https://www.ruby-forum.com/t/serving-autogenerated-files-to-users/72048/2 "2006-10-13T21:55:48Z")

</div>

> where should i generate the files to if i want the user to be able to  
> download them after they generate? anywhere in the public folder? also,  
> what is the ‘default’ path? public? so if make a hyperlink that has  
> href="/pdfs/cust1.pdf" would that point to RAILS\_ROOT +  
> ‘/public/pdfs/cust1.pdf’ ???

I’d use the send\_file method in a controller action to allow the user to  
download it. Then it doesn’t matter where you store the file, as long as  
your application can access it.
