2013-07-27 90 views
0

我試圖解決我最近有一個問題,部署從github生產分支cap: production deploy:migrations到我的服務器。問題與部署我的紅寶石軌應用程序

我看到了一個潛在的解決方案是按照這個頁面:http://www.kudelabs.com/2012/03/28/rails-3-2-cap-deploy-with-assets

但是我在rake assets:precompile部分有錯誤,本地運行它。終端建議我做 bundle exec rake assets:precompile,我做到了,但我得到了以下幾點:

[email protected]:~/myapp# bundle exec rake assets:precompile 
DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from /usr/lib/ruby/vendor_ruby/activerecord.rb:2) 
/usr/bin/ruby1.8 /usr/local/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets 
DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from /usr/lib/ruby/vendor_ruby/activerecord.rb:2) 
rake aborted! 
Received wrong number of arguments. [nil] 
/var/lib/gems/1.8/gems/omniauth-1.1.0/lib/omniauth/strategy.rb:136:in `initialize' 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:43:in `new' 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:43:in `build' 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `build' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:282:in `inject' 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `each' 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `inject' 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `build' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:470:in `build_middleware_stack' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application/finisher.rb:31 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `run_initializers' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing' 
/home/christophecompaq/myapp/config/environment.rb:5 
/var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require' 
/var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require' 
/var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency' 
/var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:103:in `require_environment!' 
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:292:in `initialize_tasks' 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/sprockets/assets.rake:93 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/sprockets/assets.rake:60 
Tasks: TOP => environment 
(See full trace by running task with --trace) 
rake aborted! 
Command failed with status (1): [/usr/bin/ruby1.8 /usr/local/bin/rake asset...] 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/sprockets/assets.rake:12:in `ruby_rake_task' 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task' 
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/sprockets/assets.rake:29 
Tasks: TOP => assets:precompile 
(See full trace by running task with --trace) 
[email protected]:~/myapp# 

誰能告訴我在哪裏的問題可能是什麼?

回答

0

如果這是初始部署,儘量去除

load 'deploy/assets' 

然後嘗試

cap deploy:setup 
cap deploy:cold 

在這種情況下,你的應用程序將被部署,但沒有任何資產:) 然後,你需要加上:

#to the top of your deploy.rb namespace :deploy block 
namespace :assets do 
    task :precompile, :roles => :web do 
    from = source.next_revision(current_revision) 
    if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ lib/assets/ app/assets/ | wc -l").to_i > 0 
        run_locally("rake assets:clean && rake assets:precompile") 
        run_locally "cd public && tar -jcf assets.tar.bz2 assets" 
        top.upload "public/assets.tar.bz2", "#{shared_path}", :via => :scp 
        run "cd #{shared_path} && tar -jxf assets.tar.bz2 && rm assets.tar.bz2" 
        run_locally "rm public/assets.tar.bz2" 
        run_locally("rake assets:clean") 
       else 
        logger.info "Skipping asset precompilation because there were no asset changes" 
       end 
      end 

      task :symlink, roles: :web do 
       run ("rm -rf #{latest_release}/public/assets && 
        mkdir -p #{latest_release}/public && 
        mkdir -p #{shared_path}/assets && 
        ln -s #{shared_path}/assets #{latest_release}/public/assets") 
      end 
     end 

然後重新檢查,如果你有這在你的production.rb

config.serve_static_assets = false 

# Compress JavaScripts and CSS 
config.assets.compress = true 

# Don't fallback to assets pipeline if a precompiled asset is missed 
config.assets.compile = false 

# Generate digests for assets URLs 
config.assets.digest = true 

所有這些工作後,改變一些東西在你的資產,例如在application.css添加新的生產線,這將告訴「任務:預編譯」來真的precomlile和上傳新的資產,因爲增加了新的資產..

+0

感謝您的提示,但它不是最初的部署 - 我已經部署了幾個星期,不知道我改變了什麼導致了這個錯誤。在我的環境/ production.rb中,我的設置都與您提供的設置相匹配。 – CHarris