Shared public directories

technicalpickles edited this page Mar 8, 2011 · 3 revisions

It's pretty common to have uploaded assets in a Rails application using paperclip, attachment_fu, carrier_wave, etc. One concern with having this in a deployed environment is that files would be uploaded to a directory like:

/srv/your_app/current/public/photos

But here's a problem. You do a deploy, and they go missing. Oh no! /srv/your_app/current points to a particular release, so when you redeploy, you create a new deploy, and the files keep on living in the original release.

Fortunately, moonshine handles this, but we just have to tell it what directories you need. We can do this by updating config/moonshine.yml:

:app_symlinks:
  - photos

Now, just deploy, and the initial /srv/your_app/shared/photos will be created by moonshine, and will be symlinked into the latest release. No more missing files!