为什么rails3在我的应用程序中找不到ApplicationController
在 Rails3 应用程序中,我不断收到
..gems/activesupport-3.0.0.beta/lib/active_support/dependency.rb:459:in 'load_missing_constant': uninitializedconstant ApplicationController (NameError)
即使 < code>app/controllers/application_controller.rb 存在且有效。问题是什么
In a Rails3 Application I keep getting
..gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:459:in 'load_missing_constant': uninitialized constant ApplicationController (NameError)
Even though app/controllers/application_controller.rb
exists and is valid. What is the problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
造成这种情况的原因可能有多种,但最让我困扰的是我的主目录中有一个 config.ru 文件:
Rails3 尝试找出应用程序的根目录在哪里。其逻辑是开始在目录
../railties/lib/rails/application
中查找,然后沿着路径查找包含config.ru
的目录,并假设这是应用程序根目录 - 如果没有找到,则当前工作目录是应用程序根目录。如果您的 Gems 安装在您的主目录的子目录中(RVM、Local Gems 和 Bundler 执行此操作),那么在某一时刻,它将检查您的主目录中是否存在
config.ru
。如果存在,它将尝试从您的主目录加载应用程序。解决方案是在您的主目录中不要有
config.ru
There are probably several causes of this, but the one that got me was having a
config.ru
file in my home directory:Rails3 attempts to figure out where your application's root directory is. The logic for this is begin looking in the directory
../railties/lib/rails/application
, and then walking up the path looking for a directory withconfig.ru
and assuming that is the app root - if none is found then the current working directory is the app root.If your Gems are installed in a subdirectory of your home dir (RVM, Local Gems and Bundler do this) then at one point this will check for the existence of
config.ru
in your home dir. If this exists it will try to load the application from your home dir.The solution is to not have
config.ru
in your home dir