我只使用一个文件:config/deploy.rb
多个任务。如果您不使用它,请忽略 RVM 业务。像这样:
task :staging do
set :rails_env, 'staging'
role :app, "staging.example.com"
role :web, "staging.example.com"
role :db, "staging.example.com", :primary => true
end
task :production do
set :rails_env, 'production'
set :branch, 'master'
# RVM integration as specified at https://rvm.beginrescueend.com/integration/capistrano/
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano"
set :rvm_ruby_string, 'ruby-version@gemset'
set :rvm_type, :user
role :app, "prod.example.com"
role :web, "prod.example.com"
role :db, "prod.example.com", :primary => true
end
cap staging deploy
然后您使用and进行部署cap production deploy
。