views:

67

answers:

1

I am generating some large files in my Rails application. Fortunately, they only need to be generated once. I would like to save these files to disk so that I don't have to generate them again.

Which directory in my Rails application is the most appropriate place to put application generated files?

Thanks!

+2  A: 

If security of the files is not an issue you can put them in a subdirectory of public (for example, public/assets) which in your deploy script is symlinked to a directory in shared/public so that when you redeploy the files are retained.

If security is an issue, the solution is similar, though you would not want the directory to be web accessible. Instead you would use a controller to control access and serve up the files with send_file.

Luke Francl
I understand that I can use send_file, In fact I currently do with the data. But what directory should I store the data in, assuming that security is an issue?
JP
You can store them where ever you like, as long as it's not web accessible. In a typical Rails deployment, there's a shared directory for stuff that's not in the repository. You can make a subdirectory of that (like shared/assets) and put the files there.
Luke Francl