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

Rails 5 Beta: Put eager_load_paths config on initializer throw frozen array exception

我遵循了 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.

但是当我在 config/initializers/eager_load.rb 中添加 Rails.application.config.eager_load_paths << Rails.root.join('lib') 时。

它抛出 <top (required)>': can't modify frozen Array (RuntimeError)

是的,如果我把它放在 config/application.rb 里面就可以了。

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

config/initializers/xxx.rb 中试试这个:

Rails.application.config.eager_load_paths += [Rails.root.join('lib')]