Capistrano删除回形针图像 [英] Capistrano Deleting Paperclip Images

查看:81
本文介绍了Capistrano删除回形针图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,每次我限制从所有用户中删除所有图像时,Capistrano都会删除数据库中的所有图像。通常,我要做的就是用capistrano删除的相同图像重新填充数据库。我已经附上了deploy.rb文件,有人可以给我一些启示。

For some reason Capistrano deletes all the images in my database every time I cap all the images get removed from all the users. Typically what I have done is have to refill the databased with the same images that had been delete by capistrano. I've attached my deploy.rb file, can someone give me some insight.

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年后,同样的麻烦...

2 years later, same trouble...

这是我的解决办法。在您的deploy.rb中:

Here's my fix. In your 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)中,并在每次部署时创建符号链接。

This will store your images in yourapp/shared/system (instead of yourapp/current/system) and create symlinks on each deploy.

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

这篇关于Capistrano删除回形针图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆