2
我想添加一個模塊到我的Rails 3.1應用程序,我已經能夠做到這一點,但它現在無法使用我添加的最新模塊。任何想法在LIB不勝感激rails3.1自動加載失敗
在application.rb中
# Custom directories with classes and modules you want to be autoloadable. config.autoload_paths += %W(#{Rails.root}/app/workers #{Rails.root}/lib/validators #{Rails.root}/lib/content_items #{Rails.root}/lib/booher_modules )
/booher_modules/mongoid_counter_cache.rb
module Mongoid module CounterCache extend ActiveSupport::Concern module ClassMethods def counter_cache(options) ... some stuff ...
現在vote.rb:
class Vote include Mongoid::Document include Mongoid::Timestamps include Mongoid::CounterCache
每當我試着啓動應用程序,我得到未初始化的常量錯誤:
Users/Tim/Sites/polco/app/models/vote.rb:4:in `': uninitialized constant Mongoid::CounterCache (NameError) from /Users/Tim/Sites/polco/app/models/vote.rb:1:in `' from /Users/Tim/.rvm/gems/[email protected]/bundler/gems/mongoid-ccae125ccfd8/lib/rails/mongoid.rb:66:in `load_model' ... so on
我試圖把需要vote.rb '的lib/mongoid_counter_cache.rb',但我得到:
rails c /Users/Tim/.rvm/gems/[email protected]/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:306:in `rescue in depend_on': No such file to load -- lib/mongoid_counter_cache (LoadError)
我現在有同樣的問題,你是否修復它? – jlstr