简体   繁体   English

Rails autoload_paths在Rails控制台中无法正常工作

[英]Rails autoload_paths doesn't work properly in rails console

I've created components folder in the root of rails 5 project and added it to autoload_paths like below: 我已经在rails 5项目的根目录中创建了components文件夹,并将其添加到如下所示的autoload_paths中:

In config/application.rb: 在config / application.rb中:

config.autoload_paths += %W(#{config.root}/components)
config.eager_load_paths += %W(#{config.root}/components)

But the files inside components doesn't load when I tested in rails console. 但是,当我在Rails控制台中进行测试时,组件内部的文件不会加载。 I guess this is something related to cache issue... Any ideas ? 我想这与缓存问题有关...有什么想法吗?

Did you set eager_load as true in environment config ? 您是否在环境配置中将eager_load设置为true?

For example, in config/environments/development.rb: 例如,在config / environments / development.rb中:

config.eager_load = true

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

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