Here’s a “hierarchal summary” of The Rails startup process from a paragliders perspective – artweb design.
By hierarchal, I mean its organized by how the code is executed. By summary, I mean things that I was interested in.
Rais app starts by running environment.rb
- boot.rb is required (require File.join(File.dirname(__FILE__), ‘boot’))
- Defines RAILS_ROOT constant (points to Rails app location)
- branches out to different boot mechanisms for booting up Rails from the vendor/rails directory or from the Rails gem respectively
- Rails::Initializer #run called (sets $LOAD_PATH to the Rails libraries and your application)
- Rails::Initializer #run called again (this time with the config code block defined in environment.rb)
- Rails::Initializer #process called
- #load_environment (environment loaded from config/environments)
- plugins and observers the routing system are loaded and initialized (in this order)
- Then the after_initialize callback is executed by calling all blocks that have been registered through config.after_initialize by now
- Lastly the application initializers are loaded from config/initializers
- This has been introduced in Rails 2.0 that allows you to keep your environment.rb clean
- example: config/initializers/exception_notifier.rb
- Rails::Initializer #process called