Rails 5 Beta: Add eager_load_paths configuration on initialization

I followed the comments in config / application.rb which

# 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. 

But when I added Rails.application.config.eager_load_paths << Rails.root.join('lib') to config/initializers/eager_load.rb .

It throws <top (required)>': can't modify frozen Array (RuntimeError)

Yes, it works if I put it inside config/application.rb .

I want to know why this does not work on the initializer and how to make it work using the convention?

+5
source share
1 answer

Try this instead of config/initializers/xxx.rb :

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

Source: https://habr.com/ru/post/1239317/


All Articles