# Deployment question: How do I symlink to a shared images fol

**URL:** <https://www.ruby-forum.com/t/deployment-question-how-do-i-symlink-to-a-shared-images-fol/113357>\
**Category:** Deployment\
**Created:** [August 30, 2007, 10:29am UTC](https://www.ruby-forum.com/t/deployment-question-how-do-i-symlink-to-a-shared-images-fol/113357 "2007-08-30T10:29:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/4491bb/32.png) [@Ivan\_V](https://www.ruby-forum.com/u/Ivan_V)\
**Post date:** [August 30, 2007, 10:29am UTC](https://www.ruby-forum.com/t/deployment-question-how-do-i-symlink-to-a-shared-images-fol/113357/1 "2007-08-30T10:29:39Z")

</div>

Hi,  
I’m deploying my web app with Capistrano 2, my users have content  
which is stored in the public/images folder and I need this to be  
stored outside the app, probably in the shared folder, but where I’m  
having trouble is when I deploy the app, 1. I can’t get symlinks to  
work from images -\> …/…/shared/system/images and I don’t know how to  
get Capistrano to recreate this link after each deploy.

Any ideas?

---

<div class="post-metadata">

**Author:** ![Ivan\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/4491bb/32.png) [@Ivan\_V](https://www.ruby-forum.com/u/Ivan_V)\
**Post date:** [August 30, 2007, 11:30am UTC](https://www.ruby-forum.com/t/deployment-question-how-do-i-symlink-to-a-shared-images-fol/113357/2 "2007-08-30T11:30:50Z")

</div>

Hi Ivan

here’s what I do with Capistrano 1 (if you already know this and I  
didn’t understand your post well enough, just ignore it 🙂

desc “After symlinking current version, install database.yml, assets,  
and update rights”  
task :after\_update\_code do

# We do not have database.yml under SVN as we don’t want anyone

having

# access to SVN to be able to access the production database.

# Link it from the shared folder.

run “ln -s #{deploy\_to}/#{shared\_dir}/config/database.yml  
#{current\_release}/config/database.yml”

# The assets folder must be kept between releases

run “rmdir #{current\_release}/public/assets” # remove the folder  
present for development  
run “ln -s #{deploy\_to}/#{shared\_dir}/assets #{current\_release}/  
public”

…  
end

cheers!

– Thibaut

---

<div class="post-metadata">

**Author:** ![Ivan\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/4491bb/32.png) [@Ivan\_V](https://www.ruby-forum.com/u/Ivan_V)\
**Post date:** [August 30, 2007, 1:29pm UTC](https://www.ruby-forum.com/t/deployment-question-how-do-i-symlink-to-a-shared-images-fol/113357/3 "2007-08-30T13:29:10Z")

</div>

Thanks for that Thibaut,

I can see how it could be modified for what I need, I’ll give it a go.

Cheers.

---

<div class="post-metadata">

**Author:** ![Ivan\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/4491bb/32.png) [@Ivan\_V](https://www.ruby-forum.com/u/Ivan_V)\
**Post date:** [August 30, 2007, 3:10pm UTC](https://www.ruby-forum.com/t/deployment-question-how-do-i-symlink-to-a-shared-images-fol/113357/4 "2007-08-30T15:10:26Z")

</div>

Hi Ivan,

one common mistake when creating symlinks using relative paths for the  
target is specifying the relative path relative to the current directory  
and not relative to the new symlinks directory.

example:

the following does not work. The created symlink in public/ is pointing  
at RAILS\_ROOT/shared.

cd RAILS\_ROOT  
ln -s …/shared/system/images public/

the correct way is:

cd RAILS\_ROOT  
ln -s …/…/shared/system/images public/

The example recipe that Thibaut Barrère gave you avoids this problem by  
using full absolute paths (provided by the deploy\_to and current\_release  
variables).

Hope this helps,

John.

–  
[http://www.brightbox.co.uk](http://www.brightbox.co.uk) - UK Rails Xen Hosting
