Reputation: 45
The controllers, models, etc are loaded from active_support/dependencies.rb. But where is the code that goes through the controllers and models and ask dependencies.rb to load each one of them?
Upvotes: 1
Views: 511
Reputation: 6808
If you put the following code in a controller file (outside of the class, preferably):
Rails.logger.info("*"*80)
Rails.logger.info(caller)
Rails.logger.info("*"*80)
And start your app in production mode you can see a complete stack trace of the initialize call that resulted in the controller being eager loaded. In development, controllers are not eager loaded.
The most critical line checks the Rails configuration and decides whether to eager load all the files.
railties-3.2.11/lib/rails/application/finisher.rb:53
Which calls the railties eager_load! method
Upvotes: 1