Saving images in shared directory w/ Capistrano/SVN?


#1

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


#2

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


#3

2006/3/31, Gokhan A. 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
for details.

Bye !


#4

François Beausoleil wrote:

2006/3/31, Gokhan A. 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
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


#5

I just blogged this:
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/, 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