我需要在本地计算机上预编译资源,并在使用资源预编译的capistrano进行部署之后。用于本地预编译资产的自定义rake任务rails 3.2.8
我已经加入到development.rb
:
config.assets.prefix = "/dev-assets"
也,我已经加入到application.rb
config.assets.initialize_on_precompile = false
除了手动执行rake assets:precompile
,我想使从自动化Capistrano的文件,清理资产,上传此过程...等等。我曾尝试与此自定义任务
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
但我得到一个错误:
/config/deploy.rb:73:in `block (3 levels) in load': undefined method `[]' for nil:NilClass (NoMethodError)
我怎么能预编译本地和上传与Capistrano的后资产?
谢谢,但我编辑了这个问题,错误不同的是其他错误。谢谢! – hyperrjas
你能给出更多关于错误的背景吗?显然你的deploy.rb脚本试图访问那些不存在的东西(比如也许是一个环境散列?)你的部署脚本在谎言的周围是什么样子的? –
我修复了错误。修复是在下一个答复。非常感谢你! – hyperrjas