# Capistrano and uploads to the public directory

**URL:** <https://discuss.rubyonrails.org/t/capistrano-and-uploads-to-the-public-directory/6765>\
**Category:** rubyonrails-talk\
**Created:** [January 5, 2007, 9:39pm UTC](https://discuss.rubyonrails.org/t/capistrano-and-uploads-to-the-public-directory/6765 "2007-01-05T21:39:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charles\_Brian\_Quinn](https://avatars.discourse-cdn.com/v4/letter/c/8797f3/32.png) [@Charles\_Brian\_Quinn](https://discuss.rubyonrails.org/u/Charles_Brian_Quinn)\
**Post date:** [January 5, 2007, 9:39pm UTC](https://discuss.rubyonrails.org/t/capistrano-and-uploads-to-the-public-directory/6765/1 "2007-01-05T21:39:27Z")

</div>

You'll want to create a shared dir in the system/shared directory capistrano sets up for you.

You can add this directory and make use of capistrano's callback, the after\_update\_code which runs after it checks out a new release into the releases dir to re-link this every time.

You can do something like this:

desc "Tasks to execute after code update" task :after\_update\_code, :roles =\> [:app, :db] do

&nbsp;&nbsp;# relink a shared public directory &nbsp;&nbsp;run "ln -nfs #{deploy\_to}/#{shared\_dir}/uploads #{release\_path}/public/uploads" end

That way you now have a symlink similar to how it handles your log directory.

Hope that helps,

---

<div class="post-metadata">

**Author:** ![Tom\_Mornini1](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@Tom\_Mornini1](https://discuss.rubyonrails.org/u/Tom_Mornini1)\
**Post date:** [January 5, 2007, 10:07pm UTC](https://discuss.rubyonrails.org/t/capistrano-and-uploads-to-the-public-directory/6765/2 "2007-01-05T22:07:21Z")

</div>

Capistrano automatically creates a symlink:

&nbsp;&nbsp;&nbsp;RAILS\_ROOT/public/system -\> RAILS\_ROOT/../shared/system

To build on this, I add symlinks to the repo, so in this case:

&nbsp;&nbsp;&nbsp;RAILS\_ROOT/public/uploads -\> RAILS\_ROOT/public/system/uploads

I them set svn:ignore on public to ignore 'system', and create a non- svn controlled directory in the working copy, in this case:

&nbsp;&nbsp;&nbsp;mkdir -p RAILS\_ROOT/public/system/uploads

I find this more convenient, reliable, and traceable than creating symlinks on-the-fly via Capistrano.

Charles' method is also perfectly reasonable.
