Rails lib包括 [英] Rails lib includes
本文介绍了Rails lib包括的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对lib目录中定义的模块有一个令人费解的问题
I have a puzzling issue regarding modules defined in the lib dir
我有两个文件
#lib/authentication.rb
module Authentication
end
#lib/test_module.rb
module TestModule
end
In我的应用程序控制器
In my application controller I have
class ApplicationController < ActionController::Base
include Authentication
include TestModule
end
验证模块正确加载,但TestModule没有
The Authentication Module loads properly but the TestModule does not
我得到未初始化的常量ApplicationController :: TestModule
I get "uninitialized constant ApplicationController::TestModule"
我很难过......任何人?
I am stumped... anyone?
编辑:有谁知道我可以在哪里调试这个?
Does anyone know where I could look to debug this?
推荐答案
在ApplicationController文件的顶部添加 require'lib / test_module'
可能有帮助
Adding require 'lib/test_module'
at the top of your ApplicationController file might help
这篇关于Rails lib包括的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文