The Initializer is responsible for processing the Rails configuration, such as setting the $LOAD_PATH, requiring the right frameworks, initializing logging, and more. It can be run either as a single command that’ll just use the default configuration, like this:
Rails::Initializer.run
But normally it’s more interesting to pass in a custom configuration through the block running:
Rails::Initializer.run do |config| config.frameworks -= [ :action_web_service ] end
This will use the default configuration options from Rails::Configuration, but allow for overwriting on select areas.
| Public Attributes | |
|---|---|
| configuration | The Configuration instance used by this Initializer instance. |
| loaded_ |
The set of loaded plugins. |
| Public Methods | |
|---|---|
| add_ |
Add the load paths used by support functions such as the info controller |
| after_ |
Fires the user-supplied after_initialize block (Configuration#after_initialize) |
| check_ |
Check for valid Ruby version This is done in an external file, so we can use it from the `rails` program as well without duplication. |
| initialize_ |
Sets the BREAKPOINT_SERVER_PORT if Configuration#breakpoint_server is true. |
| initialize_ |
This initialization routine does nothing unless :active_record is one of the frameworks to load (Configuration#frameworks). If it is, this sets the database configuration from Configuration#database_configuration and then establishes the connection. |
| initialize_ |
Sets the dependency loading mechanism based on the value of Configuration#cache_classes. |
| initialize_ |
This initialzation sets $KCODE to ‘u’ to enable the multibyte safe operations. Plugin authors supporting other encodings should override this behaviour and set the relevant default_charset on ActionController::Base |
| initialize_ |
Sets the logger for ActiveRecord, ActionController, and ActionMailer (but only for those frameworks that are to be loaded). If the framework’s logger is already set, it is not changed, otherwise it is set to use RAILS_DEFAULT_LOGGER. |
| initialize_ |
Initializes framework-specific settings for each of the loaded frameworks (Configuration#frameworks). The available settings map to the accessors on each of the corresponding Base classes. |
| initialize_ |
Sets the template_root for ActionController::Base and ActionMailer::Base (but only for those frameworks that are to be loaded). If the framework’s template_root has already been set, it is not changed, otherwise it is set to use Configuration#view_path. |
| initialize_ |
If the RAILS_DEFAULT_LOGGER constant is already set, this initialization routine does nothing. If the constant is not set, and Configuration#logger is not nil, this also does nothing. Otherwise, a new logger instance is created at Configuration#log_path, with a default log level of Configuration#log_level. |
| initialize_ |
If ActionController is not one of the loaded frameworks (Configuration#frameworks) this does nothing. Otherwise, it loads the routing definitions and sets up loading module used to lazily load controllers (Configuration#controller_paths). |
| initialize_ |
|
| initialize_ |
Loads support for "whiny nil" (noisy warnings when methods are invoked on nil values) if Configuration#whiny_nils is true. |
| load_ |
Loads the environment specified by Configuration#environment_path, which is typically one of development, testing, or production. |
| load_ |
|
| load_ |
Loads all plugins in config.plugin_paths. plugin_paths defaults to vendor/plugins but may also be set to a list of paths, such as |
| new | Create a new Initializer instance that references the given Configuration instance. |
| process | Sequentially step through all of the available initialization routines, in order: |
| require_ |
Requires all frameworks specified by the Configuration#frameworks list. By default, all frameworks (ActiveRecord, ActiveSupport, ActionPack, ActionMailer, and ActionWebService) are loaded. |
| run | Runs the initializer. By default, this will invoke the #process method, which simply executes all of the initialization routines. Alternately, you can specify explicitly which initialization routine you want: |
| set_ |
Set the paths from which Rails will automatically load source files, and the load_once paths. |
| set_ |
Sets the RAILS_CONNECTION_ADAPTERS constant based on the value of Configuration#connection_adapters. This constant is used to determine which database adapters should be loaded (by default, all adapters are loaded). |
| set_ |
Set the $LOAD_PATH based on the value of Configuration#load_paths. Duplicates are removed. |
| Protected Methods | |
|---|---|
| find_ |
Return a list of plugin paths within base_path. A plugin path is a directory that contains either a lib directory or an init.rb file. This recurses into directories which are not plugin paths, so you may organize your plugins within the plugin path. |
| load_ |
Load the plugin at path unless already loaded. |
| plugin_ |
|
| plugin_ |
|
<code/>and<pre/>for code samples.