0

제 레이크 작업이 로컬 컴퓨터에서 실행되고 있지만 프로덕션에서는 실행되지 않는 이상한 문제가 있습니다.레이크가 중단되었습니다! 초기화되지 않은 상수 User :: UserGroup

레이크 중단! 초기화되지 않은 상수 사용자 : 사용자 그룹 나는 그것의 추적을 실행

출력 다음있어 생산에서 같은 시도 다음과 같은 오류를 얻기

$ RAILS_ENV = 생산 번들 exec 레이크 청구 : 송장 - 추적

** 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 

이상한 부분은 내 로컬 컴퓨터에서 모두 정상적으로 작동하고 있습니다. 어떤 제안?

+0

내 레이크 작업에서 환경 변수 작업을 사용 중입니다 : invoices => : environment do –

답변

0

레이크 작업 소스 코드를 넣을 수 있습니까?

DESC "내 작업 설명" 작업 : my_task_name => :

보통 당신은 (AR 문제 피하기 위해) 이런 식으로 뭔가를 작성해야 환경이 할을 #의 작업 코드 여기 끝

+0

고마워요 @rorra가이 config.threadsafe에서 내 config/production.rb 파일을 변경하여 문제를 해결했습니다! ENV [ 'THREADSAFE'] == 'off'가 아닌 경우 --config.threadsafe !, config.dependency_loading = true이면 rails_rake_task. 그러나 이것이 이것으로 무엇을 할 것인가에 대해서는 여전히 불명확하다. –

1
레일 마이그레이션을 실행할 때이 특급,

class SomeNameThatsNotUsers < ActiveRecord::Migration 
    ... 

을 :

내 생각 엔 그냥 마이그레이션이 20120221123456_users.rb 같은 것을라는 추가했는지, 그리고 그 안에, 당신은 클래스를 정의하는 파일을 실행 한 다음 클래스를 인스턴스화하고 해당 클래스 인스턴스에서 #up 또는 #down을 호출하십시오. Rails는 인스턴스화 할 클래스를 어떻게 알 수 있습니까? 숫자 접두사와 밑줄 뒤에 오는 파일 이름 부분과 일치하기 때문에, 20120221123456_users.rb과 같은 파일 이름의 경우 클래스 이름은 Users이어야합니다.

관련 문제