Question

I have a rails application that is running cron jobs and generating reports in the form of csv files. My question is what is best practice on where I should store these files before sending them to an sftp site? My thinking is as a tempfile or in the root and then delete the file after its sent?

Was it helpful?

Solution

There's no common place for this in a rails app file structure, so it's really up to you. As long as it's a known place on the file system then it should be fine. However, a couple of pointers:

  • Avoid storing them in the OS's temporary directory (or rails' tmp directory), as these are cleared in certain cases.
  • If you're going to use capistrano to deploy your application then it's probably best to keep the files in a directory that's outside of the rails app altogether, as a deployment will swap the app directory with a fresh copy. If this is a problem, and you're determined to keep the directory within the rails app, then you will have to put it in the shared directory that capistrano creates and create a symbolic link/shortcut.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top