2
我正在將Rails 2.3.11應用程序升級到3.0.10。當我嘗試運行諸如rails console
之類的任何rails腳本或運行我的單元測試時,我在development.rb
文件中收到NameError
。在config/environments/development.rb中從lib中加載類的Rails 3問題
我打電話給一個我在lib
中定義的類,但是當development.rb
調用該類時,似乎該庫尚未加載。
我做這樣的事情:
config.cache_store = CustomMemcachedStore.new(Memcached.new(...))
我有一個文件lib/custom_memcached_store.rb
聲明
class CustomMemcachedStore < ActiveSupport::Cache::Store
我收到以下錯誤類:
~/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing': uninitialized constant CustomMemcachedStore (NameError)
from ~/app_name/config/environments/development.rb:20:in `block in <top (required)>'
在application.rb
,我已經在使用
config.autoload_paths += Dir["#{Rails.root}/lib"]
感謝您給我的任何幫助。
謝謝,需求修復它。我非常感謝你解釋爲什麼使用bootstrap.rb的代碼,而不僅僅是告訴我使用require。 – keithepley
很高興提供幫助。我不得不查找它來確定初始化程序的順序,所以我們都學到了一些東西:-) – numbers1311407