我有一个奇怪的问题,我的 rake 任务在我的本地机器上运行,但不在生产中。在 PRODUCTION 中尝试相同时出现以下错误
rake 中止!未初始化的常量 User::UserGroup
当我对其进行跟踪时,得到以下输出
$ RAILS_ENV=production bundle exec rake billing:invoices --trace
** Invoke billing:invoices (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute billing:invoices
Building invoices
rake aborted!
uninitialized constant User::UserGroup
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/base.rb:1205:in `compute_type'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/reflection.rb:162:in `klass'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/associations.rb:2107:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/associations.rb:1984:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/associations.rb:1984:in `build_join_association'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/associations.rb:1948:in `build'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/associations.rb:1956:in `block in build'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/associations.rb:1955:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/associations.rb:1955:in `build'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/associations.rb:1852:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/relation/query_methods.rb:246:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/relation/query_methods.rb:246:in `build_joins'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/relation/query_methods.rb:176:in `build_arel'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/relation/query_methods.rb:149:in `arel'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/relation/batches.rb:51:in `find_in_batches'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.0.11/lib/active_record/relation/batches.rb:20:in `find_each'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p327/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p327/bin/rake:23:in `<main>'
Tasks: TOP => billing:invoices
奇怪的是它在我的本地机器上工作正常。有什么建议么 ?