I was not able to easily get around this problem (i.e. I didn’t want to fully open the asset tree in my application.js application), so I ended up redefining the task deploy:assetsto compile the assets locally and clicking on each server in my cluster.
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and scp to server'
task :precompile, :roles => :web, :except => { :no_release => true } do
if releases.length <= 1 || capture("cd #{latest_release} && #{source.local.log(source.next_revision(current_revision))} vendor/assets/ app/assets/ | wc -l").to_i > 0
run_locally "bundle exec rake assets:precompile"
run_locally "cd public; tar -zcvf assets.tar.gz assets"
top.upload "public/assets.tar.gz", "#{shared_path}", :via => :scp
run "cd #{shared_path}; tar -zxvf assets.tar.gz"
run_locally "rm public/assets.tar.gz"
run_locally "bundle exec rake assets:clean"
else
logger.info 'Skipping asset pre-compilation because there were no asset changes'
end
end
end
end
source
share