2013-04-30 8 views
0
카피 바라와 폴터 가이스트와 RSpec을 실행할 때 나는 무작위로 다음과 같은 오류가 오전

:NoMethodError : '번호 <: 정의되지 않은 메서드`필드 NoMethodError'정의되지 않은 메서드`결과 전무에 대한 : NilClass>

NoMethodError: undefined method `result' for #<NoMethodError: undefined method `fields' for nil:NilClass> 

나는 생각 원인은 데이터베이스 연결과 관련 될 수 있습니다. 그럼, 누구든지 나 한테 그것을 확인할 수 있니? database_cleaner와 함께 truncation을 시도하겠습니다 만, 전체 suite를 truncation으로 실행하는 것은 SOOOO SLOW입니다!

이 문제를 피하고 빠른 실행 사양을 유지하는 전략을 생각해보십시오!

역 추적 :

~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1147:in `translate_exception' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:284:in `rescue in log' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `log' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:659:in `exec_query' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1256:in `select' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/query_cache.rb:61:in `block in select_all' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/query_cache.rb:75:in `cache_sql' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/query_cache.rb:61:in `select_all' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/querying.rb:38:in `block in find_by_sql' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/explain.rb:41:in `logging_query_plan' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/querying.rb:37:in `find_by_sql' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/relation.rb:171:in `exec_queries' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/relation.rb:160:in `block in to_a' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/explain.rb:41:in `logging_query_plan' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/relation.rb:159:in `to_a' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:380:in `find_first' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:122:in `first' 
~/.rvm/gems/ruby-2.0.0-p0/gems/orm_adapter-0.4.0/lib/orm_adapter/adapters/active_record.rb:17:in `get' 
~/.rvm/gems/ruby-2.0.0-p0/gems/devise-2.2.3/lib/devise/models/authenticatable.rb:192:in `serialize_from_session' 
~/.rvm/gems/ruby-2.0.0-p0/gems/devise-2.2.3/lib/devise/rails/warden_compat.rb:29:in `deserialize' 
~/.rvm/gems/ruby-2.0.0-p0/gems/warden-1.2.1/lib/warden/session_serializer.rb:35:in `fetch' 
~/.rvm/gems/ruby-2.0.0-p0/gems/warden-1.2.1/lib/warden/proxy.rb:212:in `user' 
~/.rvm/gems/ruby-2.0.0-p0/gems/warden-1.2.1/lib/warden/proxy.rb:318:in `_perform_authentication' 
~/.rvm/gems/ruby-2.0.0-p0/gems/warden-1.2.1/lib/warden/proxy.rb:104:in `authenticate' 
~/.rvm/gems/ruby-2.0.0-p0/gems/devise-2.2.3/lib/devise/controllers/helpers.rb:56:in `current_admin_user' 
./app/controllers/admin/base_controller.rb:5:in `user_for_paper_trail' 
~/.rvm/gems/ruby-2.0.0-p0/gems/paper_trail-2.7.1/lib/paper_trail/controller.rb:59:in `set_paper_trail_whodunnit' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:429:in `_run__385666484__process_action__495591669__callbacks' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb:17:in `process_action' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_controller/metal/rescue.rb:29:in `process_action' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:29:in `process_action' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:207:in `process_action' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:18:in `process_action' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:121:in `process' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in `process' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_controller/metal.rb:203:in `dispatch' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_controller/metal.rb:246:in `block in action' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `dispatch' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/journey-1.0.4/lib/journey/router.rb:56:in `each' 
~/.rvm/gems/ruby-2.0.0-p0/gems/journey-1.0.4/lib/journey/router.rb:56:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/omniauth-1.1.1/lib/omniauth/strategy.rb:177:in `call!' 
~/.rvm/gems/ruby-2.0.0-p0/gems/omniauth-1.1.1/lib/omniauth/strategy.rb:157:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/request_store-1.0.5/lib/request_store/middleware.rb:9:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/sass-3.2.5/lib/sass/plugin/rack.rb:54:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch' 
~/.rvm/gems/ruby-2.0.0-p0/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/conditionalget.rb:35:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/query_cache.rb:64:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `_run__267372543__call__960205176__callbacks' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_call_callbacks' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/rack/logger.rb:32:in `call_app' 
~/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `block in call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in `tagged' 
~/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/engine.rb:479:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/application.rb:223:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:134:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/urlmap.rb:64:in `block in call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `each' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/capybara-2.1.0/lib/capybara/server.rb:19:in `call' 
~/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service' 
~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 
~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 
~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'# /home/rafaelsouza/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1147:in `translate_exception' 
+3

오류는 당신이 전무 클래스의 메소드 필드를 호출하는 것입니다. 이 라인만으로 실수에 대해 우리가 당신에게 무엇을 말하기를 기대합니까? – fotanus

+0

내 코드 안에 있지 않다고 생각합니다. 백 트레이스로 질문을 수정했습니다. – rafaelkin

+0

단서가 있습니다. rspec 'before'와 'let let'를 사용하고 있습니다. '전에 (: each)'후크가 폴 테스터리스트의 별도 스레드에서 실행됩니까 js : true rspec example? – rafaelkin

답변

0

나는 AR 3.2.13에서 비슷한 문제에 직면했다. 오류에 대한 설명은 모든 예외를 포착하고 의미 있고 균일 한 오류로 변환하려고 시도하는 일반적인 예외 처리기가 AR 내에 있다는 것입니다. 다음은 함수 소스입니다 : 그것은 정말 데이터베이스 오류 인 경우

def translate_exception(exception, message) 
     case exception.result.error_field(PGresult::PG_DIAG_SQLSTATE) 
     when UNIQUE_VIOLATION 
     RecordNotUnique.new(message, exception) 
     when FOREIGN_KEY_VIOLATION 
     InvalidForeignKey.new(message, exception) 
     else 
     super 
     end 
    end 

모든 것이 잘 가야한다,하지만 또 다른 오류가 있다면, 예외를 (실행 시간 제한을 DelayedJobs, SIGTERM, ...를 사용하는 경우) 처리기 자체가 또 다른 예외를 throw하고 예외 메시지에서 볼 수 있습니다.

이것은 AR 3.2.13의 알려진 버그이며 3.2.14에서 수정되었습니다. 이들의

봐는 :

https://github.com/rails/rails/issues/10917

https://github.com/rails/rails/pull/9493

관련 문제