Ruby on rails 层次结构/模块的加载错误
我的目录结构如下所示:Ruby on rails 层次结构/模块的加载错误,ruby-on-rails,ruby,Ruby On Rails,Ruby,我的目录结构如下所示: \- app \- models \- services \- recommended_action |- base.rb |- other_recommended_action.rb |- random_service.rb module RecommendedAction class Base def initialize(attributes = {}) # assign the attrib
\- app
\- models
\- services
\- recommended_action
|- base.rb
|- other_recommended_action.rb
|- random_service.rb
module RecommendedAction
class Base
def initialize(attributes = {})
# assign the attributes
end
end
end
在my application.rb中,我通过
config.autoload_paths += %W(
#{config.root}/app/services/recommended_action
)
我的base.rb
文件如下所示:
\- app
\- models
\- services
\- recommended_action
|- base.rb
|- other_recommended_action.rb
|- random_service.rb
module RecommendedAction
class Base
def initialize(attributes = {})
# assign the attributes
end
end
end
但是,每当我尝试加载rails控制台时,都会出现以下错误:
无法自动加载常量Base,需要/Users/justin/project/app/services/recommended\u action/Base.rb来定义它(LoadError)
我遗漏了什么?默认情况下,应用程序中的所有内容都是自动加载的。摆脱该配置。如果不更改application.rb,它将抛出一个未定义
RecommendeAction
的错误。嗯。你使用的是哪一个rails版本?在rails 4.1.7-ruby 2.0上获得这些错误我没有任何问题