如何让capistrano在部署时编写.rvmrc文件?

Bla*_*man 5 capistrano ruby-on-rails rvm

我的git repo中包含我的本地rvmrc文件,当我部署时,我想使用不同的rvm gemeset名称等.

我有没有办法让capistrano在我部署的时候创建一个.rvmrc文件(或者如果存在则覆盖它)?

zet*_*tic 7

Capistrano的put命令可以从字符串中写入文件,如下所示:

desc 'Generate a config yaml in shared path'
  task :generate_yaml, :roles => :app do
    sphinx_yaml = <<-EOF
development: &base
  morphology: stem_en
  config_file: #{shared_path}/config/sphinx.conf
test:
  <<: *base
production:
  <<: *base
EOF
    run "mkdir -p #{shared_path}/config"
    put sphinx_yaml, "#{shared_path}/config/sphinx.yml"
  end
Run Code Online (Sandbox Code Playgroud)

注意:从制作你的Capistrano食谱书中取出的例子

put记录在Capistrano gitub回购中