Quick question: I am going to use the file_column plugin to manage
uploading
thumbnails. By default the images are stored in the public/ dir of the
rails project. The problem I see is that when capistrano redeploys a
new
build and symlinks it in none of the images will be in the new public/
dir… Does anyone have a solution for this?
Put the directory with the uploaded files into “shared” and just symlink
it
from within public to there. To automate that you can use the
after_symlink
filter to create your custom capistrano task. IF you take a closer look
at
how capistrano works, you see that the same happens with the logfile
directories.
Quick question: I am going to use the file_column plugin to manage
uploading
thumbnails. By default the images are stored in the public/ dir of the
rails project. The problem I see is that when capistrano redeploys a
new
build and symlinks it in none of the images will be in the new public/
dir… Does anyone have a solution for this?
This solution should work. I didn’t test it but it should be close.
Set an array to hold a list of model object names that have
file_columns:
set :models, %w( model_one model_two )
Create the shared directories to store images for the models that use
file_column:
task :after_setup, :roles => [:app, :web] do
models.each { |model| run “mkdir -p #{shared_path}/public/#{model}”
}
end
Create the links:
task :after_symlink, :roles => [:app, :web] do
models.each { |model| run “ln -nfs #{shared_path}/public/#{model}
#{current_path}/public/#{model}” }
end
Remember to ignore the image directories in your svn repository so you
don’t add stuff from your local development machine. Good luck!
Capistrano creates a directory structure that includes:
current (symlink into releases)
releases
shared
log
system
photos <-- (or something similar is where Roberto was suggesting.
In addition to Roberto’s spot-on advice, I’d suggest adding the
symlinks into the Subversion repository, as it will then be one
fewer step to think about.
Tom,
Thanks for clearing that up. I’m not to the deploying step yet so I
haven’t looked with depth at Capistrano yet - I just know that it will
be
the tool to use. It sounds like I should investigate it soon as it
pertains
to my immediate image upload needs
Thanks again,
Zack
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.