15

I came across the following line in a Rails application I'm maintaining:

Rails.application.eager_load!

I googled it but didn't find anything that really spelled out what it does. What does it do?

Jason Swett
  • 43,526
  • 67
  • 220
  • 351

1 Answers1

12

I believe it requires all the files in the eager load paths. So all files from your controllers to your models will get ran which will load all your rails classes. Without doing this, I think you would have to explicitly require the file of the model or controller that you need before referencing it.

Someone wrote an article pertaining to it here which talks about config.eager_load and what it does.

arjabbar
  • 6,044
  • 4
  • 30
  • 46