我是 Rails 新手。我在 lib 目录中有一个设置,如下所示:
lib/
blog/
core/
search/
base.rb
base.rb 也定义了 Base 类:
module Blog
module Core
module Search
class Base
attr_accessor :properties
def initialize(params)
@properties = {}
end
end
end
end
end
我的 application.rb 中有以下代码
config.autoload_paths += Dir["#{config.root}/lib/**/"]
当我将它包含在帖子控制器中时,我收到以下错误:
LoadError in PostsController#index
Expected /home/usr/code/blog/lib/blog/core/search/base.rb to define Base
任何想法?我正在使用带有 RVM 的 rails 3.2.5。谢谢你的每一个建议。
更新:添加了我的完整堆栈:
Started GET "/admin/posts" for 127.0.0.1 at 2012-06-08 21:06:18 +0800
LoadError (Expected /home/usr/code/blog/lib/blog/core/search/base.rb to define Base):
app/controllers/admin/base_controller.rb:5:in `<top (required)>'
app/controllers/admin/posts_controller.rb:6:in `<top (required)>'
Rendered /home/usr/.rvm/gems/ruby-1.9.3-p194@rails-3.2.5/gems/actionpack-3.2.5/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.9ms)
Rendered /home/usr/.rvm/gems/ruby-1.9.3-p194@rails-3.2.5/gems/actionpack-3.2.5/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.6ms)
Rendered /home/usr/.rvm/gems/ruby-1.9.3-p194@rails-3.2.5/gems/actionpack-3.2.5/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (7.0ms)