# Saving images in shared directory w/ Capistrano/SVN?

**URL:** <https://www.ruby-forum.com/t/saving-images-in-shared-directory-w-capistrano-svn/93386>\
**Category:** Rails\
**Created:** [April 1, 2006, 6:03am UTC](https://www.ruby-forum.com/t/saving-images-in-shared-directory-w-capistrano-svn/93386 "2006-04-01T06:03:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 1, 2006, 6:03am UTC](https://www.ruby-forum.com/t/saving-images-in-shared-directory-w-capistrano-svn/93386/1 "2006-04-01T06:03:02Z")

</div>

Hi all,

I’m using Capistrano and SVN to version control and deploy, but I’m not  
sure what to do about my images directory. I use file\_column and  
RMagick to save images to the disk under a model called “Image”, and  
they’re saved in public/image/… etc.

Each time I deploy a new version, my image folder doesn’t exist anymore.  
I don’t want to version control map my local image folder to the  
server’s image folder, so what should I do?

Is it possible to save my images in a shared folder and let Capistrano  
know about that?

Thanks,  
Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 1, 2006, 6:04am UTC](https://www.ruby-forum.com/t/saving-images-in-shared-directory-w-capistrano-svn/93386/2 "2006-04-01T06:04:28Z")

</div>

Jeff C.man wrote:

> Hi all,
> 
> I’m using Capistrano and SVN to version control and deploy, but I’m not  
> sure what to do about my images directory. I use file\_column and  
> RMagick to save images to the disk under a model called “Image”, and  
> they’re saved in public/image/… etc.
> 
> Each time I deploy a new version, my image folder doesn’t exist anymore.  
> I don’t want to version control map my local image folder to the  
> server’s image folder, so what should I do?
> 
> Is it possible to save my images in a shared folder and let Capistrano  
> know about that?
> 
> Thanks,  
> Jeff

Yep, use shared folder and write recipie in cap to create sym links from  
public/image

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 1, 2006, 6:37am UTC](https://www.ruby-forum.com/t/saving-images-in-shared-directory-w-capistrano-svn/93386/3 "2006-04-01T06:37:38Z")

</div>

2006/3/31, Gokhan A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Jeff C.man wrote:
> 
> > Is it possible to save my images in a shared folder and let Capistrano  
> > know about that?
> 
> Yep, use shared folder and write recipie in cap to create sym links from  
> public/image

Make a symlink on the production system and svn add the symlink.  
Subversion will notice it is a symlink and will recreate the symlink  
on subsequent checkouts.

You need SVN 1.1 or better for this to work. See  
[http://svnbook.red-bean.com/nightly/en/svn.advanced.props.html#svn.advanced.props.special.special](http://svnbook.red-bean.com/nightly/en/svn.advanced.props.html#svn.advanced.props.special.special)  
for details.

Bye !

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 1, 2006, 6:40am UTC](https://www.ruby-forum.com/t/saving-images-in-shared-directory-w-capistrano-svn/93386/4 "2006-04-01T06:40:33Z")

</div>

FranÃ§ois Beausoleil wrote:

> 2006/3/31, Gokhan A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > Jeff C.man wrote:
> > 
> > > Is it possible to save my images in a shared folder and let Capistrano  
> > > know about that?
> > 
> > Yep, use shared folder and write recipie in cap to create sym links from  
> > public/image
> 
> Make a symlink on the production system and svn add the symlink.  
> Subversion will notice it is a symlink and will recreate the symlink  
> on subsequent checkouts.
> 
> You need SVN 1.1 or better for this to work. See  
> [Properties](http://svnbook.red-bean.com/nightly/en/svn.advanced.props.html#svn.advanced.props.special.special)  
> for details.
> 
> Bye !

Wow, that is nice. I went ahead and made a cap recipe to recreate the  
symlink, but that’s pretty much seamless. Thanks!

Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 1, 2006, 11:22pm UTC](https://www.ruby-forum.com/t/saving-images-in-shared-directory-w-capistrano-svn/93386/5 "2006-04-01T23:22:36Z")

</div>

I just blogged this:  
[http://kylemaxwell.com/articles/2006/04/01/using-filecolumn-with-capistrano](http://kylemaxwell.com/articles/2006/04/01/using-filecolumn-with-capistrano)

* * *

I assume that you already have basic familiarity iwth Ruby, Rails, the  
Rails plugin system, Capistrano, and FileColumn (or file\_column), but  
not neccessarily the internals of the above programs.

Let’s get them all working together.

First, for convienience, you should choose the name of a folder in  
your site for the file\_column content to reside. I usually set this to  
RAILS\_ENV, so that I can run with multiple environments on one rails  
app. Your file\_column content is tied to a specific database, and if  
multiple environments use the same folder, then you have the potential  
to overwrite data.

Ok, so you’ve chosen your folder name. I’ll assume you’ve stuck to my  
convention of [www.yoursite.com/RAILS\_ENV/](http://www.yoursite.com/RAILS_ENV/), but you can choose a  
prettier name if you’d like. We’re going to make file\_column  
understand this preference in one of two ways:

1. Call file\_column with options:

file\_column :some\_image,  
:root\_path =\> File.join(RAILS\_ROOT, “public”, RAILS\_ENV),  
:web\_root =\> RAILS\_ENV + “/”

The problem with this is that its not very DRY. To make it DRY, you  
should:

1. Modify the DEFAULT\_OPTIONS hash directly, in  
vendor/plugins/file\_column/lib/file\_column.rb, around line 500 or so.

Now you’ve got to make Capistrano symlink this folder into another  
folder in your shared directory. To do this, add the following to your  
deploy.rb recipe. Then run `cap setup`

task :after\_setup  
run “mkdir #{shared\_path}/production”  
end

task :after\_symlink do  
run “ln -nfs #{shared\_path}/production  
#{release\_path}/public/production”  
end

–  
Kyle M.  
Chief Technologist  
E Factor Media // FN Interactive  
removed\_email\_address@domain.invalid  
1-866-263-3261
