cache_money 'nil.repository' ошибка - PullRequest
2 голосов
/ 28 августа 2009

Я просто пробую гем cache_money в существующем приложении и получаю эту ошибку:

NoMethodError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.repository)

Я думаю, что мой memached сервер настроен правильно. Я использую Rails 2.2.2

EDIT:

Трассировка стека:

NoMethodError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.repository):
    (__DELEGATION__):2:in `__send__'
    (__DELEGATION__):2:in `repository'
    /usr/lib/ruby/gems/1.8/gems/nkallen-cache-money-0.2.5/lib/cache_money.rb:50:in `transaction'
    /vendor/rails/activerecord/lib/active_record/transactions.rb:138:in `transaction'
    /vendor/rails/activerecord/lib/active_record/transactions.rb:178:in `with_transaction_returning_status'
    /vendor/rails/activerecord/lib/active_record/transactions.rb:146:in `save_without_trace_ActiveRecord___self_class_name__save'
    /vendor/rails/activerecord/lib/active_record/transactions.rb:158:in `rollback_active_record_state!'
    /vendor/rails/activerecord/lib/active_record/transactions.rb:146:in `save_without_trace_ActiveRecord___self_class_name__save'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:138:in `save_without_trace_ActiveRecord_save'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:41:in `trace_method_execution_with_scope'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:137:in `save_without_trace_ActiveRecord_save'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:141:in `save_without_trace_ActiveRecord_all'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:141:in `save'
    /vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:237:in `create'
    /vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:405:in `create_record'
    /vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:423:in `add_record_to_target_with_callbacks'
    /vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:405:in `create_record'
    /vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:235:in `create'
    /app/controllers/application.rb:234:in `write_audit_log'
    /app/controllers/application.rb:224:in `write_read_audit_log'
    /vendor/rails/activesupport/lib/active_support/callbacks.rb:178:in `send'
    /vendor/rails/activesupport/lib/active_support/callbacks.rb:178:in `evaluate_method'
    /vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in `call'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:662:in `run_after_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:619:in `call_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /vendor/rails/actionpack/lib/action_controller/rescue.rb:136:in `perform_action_without_caching'
    /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action_without_newrelic_trace'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
    /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
    /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action_without_newrelic_trace'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:123:in `perform_action'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:41:in `trace_method_execution_with_scope'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:109:in `perform_action'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb:18:in `trace_method_execution_no_scope'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:103:in `perform_action'
    /vendor/rails/actionpack/lib/action_controller/base.rb:524:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:524:in `process_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
    /vendor/rails/actionpack/lib/action_controller/session_management.rb:134:in `process'
    /vendor/rails/actionpack/lib/action_controller/base.rb:392:in `process'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:183:in `handle_request'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:123:in `dispatch_without_newrelic'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:122:in `synchronize'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:122:in `dispatch_without_newrelic'
    /vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb:44:in `dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:132:in `dispatch_cgi'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:39:in `dispatch'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `orig_process_client'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `orig_process_client'
    /vendor/plugins/spawn/lib/patches.rb:59:in `process_client'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load_without_new_constant_marking'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load'
    /vendor/rails/railties/lib/commands/servers/mongrel.rb:64
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
    /vendor/rails/railties/lib/commands/server.rb:49
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    script/server:3

Ответы [ 3 ]

1 голос
/ 23 апреля 2010

Я бы порекомендовал обновиться до форка ngmoco-cache-money, в котором есть много исправлений, не включенных в основной репозиторий cache-money. http://github.com/ngmoco/cache-money

1 голос
/ 20 октября 2010

Я сталкивался с этой ошибкой при использовании acts_as_taggable_on и cache-money 0.2.5.

Похоже, что @cache_config не устанавливается на ActsAsTaggableOn::Tag классе

если вы откроете cache-money-0.2.5 / lib / cash / config.rb и удалите:

   attr_reader :cache_config
   delegate :repository, :indices, :to => :@cache_config

и замените его на:

   def cache_config
     @cache_config ? @cache_config : superclass.cache_config
   end

   delegate :repository, :indices, :to => :cache_config

Это будет использовать cache_config суперкласса ActsAsTaggableOn::Tag.

У меня работает.

1 голос
/ 11 ноября 2009

Если вы используете cache_money в соответствии с его назначением (трудно судить по тому, что вы дали), это может быть ошибкой в ​​cache_money. В проекте github сообщается о других нулевых ссылочных ошибках, некоторые из которых были исправлены начиная с версии 0.2.5.

Вы можете проверить последнюю версию кода в качестве плагина в вашем проекте rails:

script/plugin git://github.com/nkallen/cache-money.git

Возможно, они исправили вашу проблему со времени вашей версии. Если это не поможет, вы можете удалить плагин из vendor/plugins/cache-money.

Если это не поможет, вы можете отправить свою проблему на систему отслеживания проблем автора по адресу http://github.com/nkallen/cache-money, и посмотреть, смогут ли они решить ее за вас.

...