Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I followed commented guidelines in config/application.rb which is

   # 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') in config/initializers/eager_load.rb.

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

Yes it is working if i put it inside config/application.rb.

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

like image 515
Yana Agun Siswanto Avatar asked Oct 30 '22 12:10

Yana Agun Siswanto


1 Answers

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

Rails.application.config.eager_load_paths += [Rails.root.join('lib')] 
like image 59
Weston Avatar answered Nov 15 '22 19:11

Weston