Hola
Hola

Reputation: 165

environment first or boot first?

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?

Upvotes: 1

Views: 150

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176372

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.

Upvotes: 1

Related Questions