Question

environment.rb starts with this:

RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|

Does this mean environment.rb starts first and calls boot.rb?

Was it helpful?

Solution

The environment.rb is the main Rails environment file. It requires the boot.rb file but the boot.rb is run before Rails::Initializer.run. In fact, the last line of boot.rb contains the following statement

# All that for this:
Rails.boot!

Please note that while the environment.rb file belongs to your Rails app, the boot.rb file is automatically updated each time you run the rake task

rake update:rails

You should never modify that file.

To better understand how Rails initialization works, Sven wrote a really helpful article called The Rails startup process from a paragliders perspective.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top