Capistrano删除回形针图像

出于某种原因,每当我将所有图像从所有用户中删除时,Capistrano都会删除我数据库中的所有图像。 通常我所做的是必须使用capistrano删除的相同图像重新填充数据库。 我已经附上了我的deploy.rb文件,有人可以给我一些见解。

require "bundler/capistrano" set :rvm_ruby_string, '1.9.3p429' set :rvm_type, :user set :user, "" set :password, "" set :domain, "" set :applicationdir, "" set :scm, :git set :repository, "" set :git_enable_submodules, 1 # if you have vendored rails set :branch, "release" set :rails_env, 'production' #set :git_shallow_clone, 1 set :scm_verbose, true # roles (servers) role :web, domain role :app, domain role :db, domain, :primary => true set :port, 22 # deploy config set :deploy_to, applicationdir set :deploy_via, :remote_cache # additional settings default_run_options[:pty] = true # Forgo errors when deploying from windows ssh_options[:forward_agent] = true #ssh_options[:keys] = %w(/home/user/.ssh/id_rsa) # If you are using ssh_keysset :chmod755, "app config db lib public vendor script script/* public/disp*"set :use_sudo, false # runtime dependencies depend :remote, :gem, "bundler", ">=1.0.0.rc.2" # tasks namespace :deploy do task :start, :roles => :app do run "touch #{current_path}/tmp/restart.txt" end task :stop, :roles => :app do # Do nothing. end desc "Restart Application" task :restart, :roles => :app do run "touch #{current_path}/tmp/restart.txt" end desc "Symlink shared resources on each release" task :symlink_shared, :roles => :app do #run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" end end after 'deploy:update_code', 'deploy:symlink_shared' namespace :bundler do desc "Symlink bundled gems on each release" task :symlink_bundled_gems, :roles => :app do run "mkdir -p #{shared_path}/bundled_gems" run "ln -nfs #{shared_path}/bundled_gems #{release_path}/vendor/bundle" end desc "Install for production" task :install, :roles => :app do run "cd #{release_path} && bundle install --without development test" end end after 'deploy:update_code', 'bundler:symlink_bundled_gems' after 'deploy:update_code', 'bundler:install' 

2年后,同样的麻烦……

这是我的修复。 在deploy.rb中:

 # Default value for linked_dirs is [] # set :linked_dirs, fetch(:linked_dirs, []).push('bin', 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system') set :linked_dirs, fetch(:linked_dirs, []).push('public/system') 

这会将您的图像存储在yourapp / shared / system(而不是yourapp / current / system)中,并在每次部署时创建符号链接。

资料来源: https : //github.com/capistrano/rails/issues/104#issuecomment-72766586

您的public/images (或Paperclip存储图像的任何位置)很可能不是共享符号链接,因此当Capistrano链接新版本时,不会复制图像。

Paperclip README文件中有关于此权利的文档,包括如何不陷入此陷阱。