Rails 5 Beta:将eager_load_paths配置放在初始化器抛出冻结数组异常上

时间:2015-12-27 22:43:31

标签: configuration eager-loading ruby-on-rails-5

我在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里面就可以了。

我想知道为什么它不能用于初始化器以及如何使用约定使其工作?

1 个答案:

答案 0 :(得分:2)

请在config/initializers/xxx.rb

中尝试此操作
Rails.application.config.eager_load_paths += [Rails.root.join('lib')]