I need precompile assets on my local machine and after make deploy with capistrano with assets precompiled.
I have added to development.rb
:
config.assets.prefix = "/dev-assets"
also, I have added to application.rb
config.assets.initialize_on_precompile = false
Instead execute rake assets:precompile
manually, I want make this process from capistrano file automated, clean assets, upload...etc. I have tried with this custom task
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
from = source.next_revision(current_revision)
if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
run_locally "bundle exec rake assets:precompile"
run_locally "rsync -zvrh --progress -e 'ssh -i #{ssh_options[:keys][0]}' public/assets #{user}{server}:#{shared_path}"
puts "cleaning up locally compiled assets"
run_locally "bundle exec rake assets:clean"
else
puts "Skipping asset pre-compilation because there were no asset changes"
end
end
end
But I get a error:
/config/deploy.rb:73:in `block (3 levels) in load': undefined method `[]' for nil:NilClass (NoMethodError)
How can I precompile assets on local and after upload with capistrano?