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:
- 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:
- 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
[email protected]
1-866-263-3261