以前工作的Rails 3.1應用程序現在無法部署。 Capistrano deploy:assets:precompile
任務遇到錯誤「Could not find table 'users'
」。Rails Capistrano部署錯誤:在rake資產上執行失敗:預編譯,在lambda的命名範圍內
我用rake --trace
在users
模型引腳這種錯誤,將其放在新添加的命名範圍:
scope :find_by_skill_offered, lambda { |skill_id|
joins(:skills).where("user_skills.offered = ? AND skills.id = ?", 'true', skill_id)
}
在我看來,該rake任務可能試圖執行拉姆達,前數據庫被鏈接,因此失敗。
這聽起來像是與this problem with factory_girl類似的問題,即在數據庫存在之前執行的代碼,但我不明白爲什麼在實際調用lambda之前會執行lambda。
堆棧跟蹤顯示了Devise路由在那裏的構建,所以也許它與此有關,但似乎很奇怪,路由代碼正在作爲deploy:assets:precompile
的一部分運行,或者我錯過了關於管道工作方式的一些信息?
在此先感謝。
更新:
也會出現這種情況與當地rake assets:precompile
(我通常只建立在服務器上的資產)。
完整的錯誤輸出和跡:
def self.find_by_skill_offered(skill_id)
joins(:skills).where("user_skills.offered = ? AND skills.id = ?", 'true', skill_id)
}
看來,這是爲Rails 3.1首選的方法:
* 18:47:58 == Currently executing `deploy:assets:precompile'
* executing "cd /home/backscratchers/development/backscratchers/releases/20111010174747 && rake --trace RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["87.106.100.151"]
[87.106.100.151] executing command
*** [err :: 87.106.100.151] ** Invoke assets:precompile (first_time)
*** [err :: 87.106.100.151] ** Execute assets:precompile
*** [err :: 87.106.100.151] ** Invoke environment (first_time)
*** [err :: 87.106.100.151] ** Execute environment
*** [err :: 87.106.100.151] rake aborted!
*** [err :: 87.106.100.151] Could not find table 'users'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb:387:in `table_structure'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb:270:in `columns'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `block (2 levels) in initialize'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `with_connection'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:92:in `block in initialize'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:706:in `yield'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:706:in `default'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:706:in `columns'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:722:in `column_names'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:735:in `column_methods_hash'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:1101:in `all_attributes_exists?'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:886:in `respond_to?'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/named_scope.rb:193:in `valid_scope_name?'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/named_scope.rb:175:in `scope'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/releases/20111010174747/app/models/user.rb:6:in `<class:User>'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/releases/20111010174747/app/models/user.rb:1:in `<top (required)>'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:225:in `load_dependency'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:348:in `require_or_load'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:489:in `load_missing_constant'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:181:in `block in const_missing'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `each'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `const_missing'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:124:in `block in constantize'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:123:in `each'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:123:in `constantize'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:528:in `block in initialize'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:550:in `yield'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:550:in `default'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:550:in `[]'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:595:in `constantize'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/devise-1.4.5/lib/devise.rb:259:in `get'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/devise-1.4.5/lib/devise/mapping.rb:101:in `to'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/devise-1.4.5/lib/devise/mapping.rb:96:in `modules'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/devise-1.4.5/lib/devise/mapping.rb:113:in `routes'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/devise-1.4.5/lib/devise/mapping.rb:82:in `initialize'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/devise-1.4.5/lib/devise.rb:289:in `new'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/devise-1.4.5/lib/devise.rb:289:in `add_mapping'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/devise-1.4.5/lib/devise/rails/routes.rb:191:in `block in devise_for'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/devise-1.4.5/lib/devise/rails/routes.rb:190:in `each'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/devise-1.4.5/lib/devise/rails/routes.rb:190:in `devise_for'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/releases/20111010174747/config/routes.rb:20:in `block in <top (required)>'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:257:in `instance_exec'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:257:in `eval_block'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:234:in `draw'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/releases/20111010174747/config/routes.rb:1:in `<top (required)>'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `block in load'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:225:in `load_dependency'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/routes_reloader.rb:29:in `block in load_paths'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/routes_reloader.rb:29:in `each'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/routes_reloader.rb:29:in `load_paths'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/routes_reloader.rb:13:in `reload!'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/routes_reloader.rb:7:in `block in initialize'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/file_update_checker.rb:32:in `call'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/finisher.rb:63:in `block (2 levels) in <module:Finisher>'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/finisher.rb:64:in `call'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/finisher.rb:64:in `block in <module:Finisher>'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `instance_exec'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `run'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:50:in `block in run_initializers'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `each'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `run_initializers'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application.rb:92:in `initialize!'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/releases/20111010174747/config/environment.rb:5:in `<top (required)>'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `block in load_dependency'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application.rb:78:in `require_environment!'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application.rb:189:in `block (2 levels) in initialize_tasks'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
*** [err :: 87.106.100.151] /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
*** [err :: 87.106.100.151] /home/backscratchers/development/backscratchers/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.0/lib/sprockets/assets.rake:11:in `block (2 levels) in <top (required)>'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]l/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
*** [err :: 87.106.100.151] /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/[email protected]/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
*** [err :: 87.106.100.151] /usr/local/rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'
*** [err :: 87.106.100.151] Tasks: TOP => environment
我已經用類方法代替lambda函數解決了這個(:技能)。凡( 「user_skills.offered = AND skills.id =?」, 'true',skill_id) }' 看來這是Rails 3.1及更高版本的首選方法。 如果任何人都可以找出前一個錯誤發生的原因,我認爲這會有用 - 這可能是Devise中的一個錯誤嗎?如果是這樣,我已經在github上創建了一個問題,讓他們看看(如果不相關的話,可以放棄!):https://github.com/plataformatec/devise/issues/1373 – Leo