简体   繁体   English

使用文件夹名称作为namspace的rails 3引发未初始化的常量错误

[英]rails 3 using folder name as namspace throws uninitialized constant error

I'm trying to upgrade an app from rails 2.3 to 3.0 and it has a file 我正在尝试将应用程序从Rails 2.3升级到3.0,并且其中包含一个文件

app/utility/interface/import/import_statistics_manager.rb

which contains 其中包含

class Utility::Interface::Import::ImportStatisticsManager         
//code here  
end

I beleive Utility::Interface::Import are the folder names in its file path but used as namespaces 我相信Utility::Interface::Import是其文件路径中的文件夹名称,但用作命名空间

This code works fine in rails 2.3 but when I try to run with rails 3.0.6 it throws a NameError 这段代码在rails 2.3上工作正常,但是当我尝试在rails 3.0.6上运行时,它将引发NameError

Error message:
   uninitialized constant Utility
Exception class:
   NameError

FYI: rails 2.3 uses ruby 1.8.7 and rails 3.0.6 uses ruby 1.9.2 仅供参考:Rails 2.3使用ruby 1.8.7,rails 3.0.6使用ruby 1.9.2

Please correct me if my understandings are not correct 如果我的理解不正确,请纠正我

For future reference (see comments on the question): 供将来参考(请参阅对该问题的评论):

It helped adding the complete app folder to the autoload paths. 它有助于将完整的app文件夹添加到自动加载路径。

See this post for further info. 请参阅此帖子以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM