Everytime I run cap deploy in the remote server I lost some unversioned files because capistrano creates a new directory and checkouts the head revision in it. But there are some files that are not versioned like users avatars (paperclip) and uploaded images which don't get copied to the new current release.
How can I workaround this?
Thanks!
Personally, I think the best way to deal with those kind of things is to store them in the shared folder and create a task in capistrano to create symlinks to the shared assets.
Here's an example from one of my projects:
set :shared_assets, %w{public/images/products public/images/barcodes}
namespace :assets do
namespace :symlinks do
desc "Setup application symlinks for shared assets"
task :setup, :roles => [:app, :web] do
shared_assets.each { |link| run "mkdir -p #{shared_path}/#{link}" }
end
desc "Link assets for current deploy to the shared location"
task :update, :roles => [:app, :web] do
shared_assets.each { |link| run "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}" }
end
end
end
before "deploy:setup" do
assets.symlinks.setup
end
before "deploy:symlink" do
assets.symlinks.update
end
Adding your paths to shared_children also works and is actually just a one-liner in your deploy.rb:
set :shared_children, shared_children + %w{public/uploads}
found it here: astonj
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With