【发布时间】:2012-04-18 12:07:58
【问题描述】:
我想在MyModule 中包含TestModule:
# in test_module.rb
module TestModule
SOMETHING = [1, 2, 3]
end
# in my_module.rb
module MyModule
include TestModule
def my_method
"testing"
end
end
我收到此错误:
Routing Error: uninitialized constant MyModule::TestModule
我已经仔细检查了 Rails 命名约定。 知道为什么这不起作用吗?
更多信息:application.rb 中的 config.autoload_paths += ... 已被注释掉。但是/lib 中的其他模块正在以某种方式加载。
更多信息 2:我认为 rails 看不到新文件 test_module.rb。如果我将新模块添加到包含模块的现有文件中,那么包含新模块就可以了。 $LOAD_PATH 或其他东西是否有某种轨道清理或刷新过程?
【问题讨论】:
标签: ruby-on-rails module routing include