Application Initialization in 20 Easy Steps
initializer.rb
Rails::Initializer is the main class that handles setting up the Rails environment
within Ruby. Initialization is kicked off by config/environment.rb, which contains the
block:
Rails::Initializer.run do |config|
# (configuration)
end
* Avalue object is an object representing a value, whose identity is defined by that value only. In other words,
two objects compare as equal if and only if they have the same state.
76 | Chapter 2: ActiveSupport and RailTies
Rails::Initializer.run yields a new Rails::Configuration object to the block. Then
run creates a new Rails::Initializer object and calls its process method, which
takes the following steps in order to initialize Rails:
1. check_ruby_version: Ensures that Ruby 1.8.2 or above (but not 1.8.3) is being
used.
2. set_load_path: Adds the framework paths (RailTies, ActionPack,* ActiveSupport,
ActiveRecord, Action Mailer, and Action Web Service) and the application??™s
load paths to the Ruby load path. The framework is loaded from vendor/rails or
a location specified in RAILS_FRAMEWORK_ROOT.
3. require_frameworks: Loads each framework listed in the frameworks configuration
option. If the framework path was not specified in RAILS_FRAMEWORK_ROOT
and it does not exist in vendor/rails, Initializer will assume the frameworks are
installed as RubyGems.
4. set_autoload_paths: Sets the autoload paths based on the values of the load_
paths and load_once_paths configuration variables.
Pages:
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123