ruby 使用Capistrano 3和rsync进行本地Rails 4资产预编译

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 使用Capistrano 3和rsync进行本地Rails 4资产预编译相关的知识,希望对你有一定的参考价值。

# Updated to work with Capistrano 3 and Rails 4; compiles assets in given stage in order
# to use settings for that stage ... rm assets when we're done

namespace :deploy do
  after :updated, "assets:precompile"
end

namespace :assets do
  desc "Precompile assets locally and then rsync to web servers"
  task :precompile do
    on roles(:web) do
      rsync_host = host.to_s # this needs to be done outside run_locally in order for host to exist
      run_locally do
        with rails_env: fetch(:stage) do
          execute :bundle, "exec rake assets:precompile"
        end
        execute "rsync -av --delete ./public/assets/ #{fetch(:user)}@#{rsync_host}:#{shared_path}/public/assets/"
        execute "rm -rf public/assets"
        # execute "rm -rf tmp/cache/assets" # in case you are not seeing changes
      end
    end
  end
end
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false

以上是关于ruby 使用Capistrano 3和rsync进行本地Rails 4资产预编译的主要内容,如果未能解决你的问题,请参考以下文章

Capistrano在升级ruby版本和puma时重启错误版本的puma

ruby 更新了Capistrano 3。

部署后缺少宝石(Ruby,Ruby on Rails,Capistrano)

Capistrano自动化部署工具安装详细过程

如何配置 capistrano 以使用我的 rvm 版本的 Ruby

使用 Capistrano 将 Ruby on Rails 应用程序部署到 Windows Azure VM 时出现超时错误