我在config / application.rb中遵循了注释指南,即
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
但是当我在Rails.application.config.eager_load_paths << Rails.root.join('lib')
中添加config/initializers/eager_load.rb
时。
抛出<top (required)>': can't modify frozen Array (RuntimeError)
是的,如果我把它放在config/application.rb
里面就可以了。
我想知道为什么它不能用于初始化器以及如何使用约定使其工作?
答案 0 :(得分:2)
请在config/initializers/xxx.rb
:
Rails.application.config.eager_load_paths += [Rails.root.join('lib')]