Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Rails.application.eager_load! do?

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?

like image 421
Jason Swett Avatar asked Jun 17 '16 19:06

Jason Swett


1 Answers

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.

like image 153
arjabbar Avatar answered Nov 01 '22 01:11

arjabbar