Forum: Ruby on Rails Capistrano and uploads to the public directory

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Alex W. (Guest)
on 2007-01-05 22:02
I need some help.  I (finally) have an app setup for capistrano
deployment.  The only issue is that the admin interface allows uploads
of some file to the public directory.

When capistrano does a deploy, I get a brand new public directory,
wiping out all the uploaded files.

I am sure other have ran into this before, there must be a solution.  I
thought about putting all the uploaded file in the same spot, but the
uploads have different purposes in multiple areas and would be awkward
to simply group them into some articficial "uploads" directory that gets
symlinked in.

Any ideas?
Mitchell H. (Guest)
on 2007-01-06 10:35
Well, I recommend creating a directory called "uploads" in your "shared"
folder in your capistrano directory and uploading them there. If you
allow people to upload directly to your released app's public directory,
then when you deploy a new revision, all those uploads will be archived.
If you instead upload them to the shared folder, you can use custom
routes to display them using send_file.

Because you said they have different purposes in multiple areas, I see
the format like this:

:area/:file

For a simple one. You can forward that route to a controller which will
then load the data from the shared folder, and use send_file to send it
directly to the browser, as if that file were really located at the
requsted URL.

Alex W. wrote:
> I need some help.  I (finally) have an app setup for capistrano
> deployment.  The only issue is that the admin interface allows uploads
> of some file to the public directory.
>
> When capistrano does a deploy, I get a brand new public directory,
> wiping out all the uploaded files.
>
> I am sure other have ran into this before, there must be a solution.  I
> thought about putting all the uploaded file in the same spot, but the
> uploads have different purposes in multiple areas and would be awkward
> to simply group them into some articficial "uploads" directory that gets
> symlinked in.
>
> Any ideas?
This topic is locked and can not be replied to.