- Inheritance
- < Object
The Configuration class holds all the parameters for the Initializer and ships with defaults that suites most Rails applications. But it‘s possible to overwrite everything. Usually, you‘ll create an Configuration file implicitly through the block running on the Initializer, but it‘s also possible to create the Configuration instance in advance and pass it in like this:
config = Rails::Configuration.new Rails::Initializer.run(:process, config)
Attributes
Name | Visibility | R/W | Description |
---|---|---|---|
action_controller | public | RW | A stub for setting options on ActionController::Base. |
action_mailer | public | RW | A stub for setting options on ActionMailer::Base. |
action_view | public | RW | A stub for setting options on ActionView::Base. |
active_record | public | RW | A stub for setting options on ActiveRecord::Base. |
active_resource | public | RW | A stub for setting options on ActiveResource::Base. |
active_support | public | RW | A stub for setting options on ActiveSupport. |
cache_classes | public | RW | Whether or not classes should be cached (set to false if you want application classes to be reloaded on each request) |
cache_store | public | RW | The specific cache store to use. By default, the ActiveSupport::Cache::Store will be used. |
controller_paths | public | RW | The list of paths that should be searched for controllers. (Defaults to app/controllers.) |
database_configuration_file | public | RW | The path to the database configuration file to use. (Defaults to config/database.yml.) |
dependency_loading | public | RW |
Enables or disables dependency loading during the request cycle. Setting
dependency_loading to true will allow new classes to be loaded during a
request. Setting it to false will disable this behavior.
Those who want to run in a threaded environment should disable this option and eager load or require all there classes on initialization. If cache_classes is disabled, dependency loaded will always be on. |
eager_load_paths | public | RW | An array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in load_paths. |
frameworks | public | RW | The list of rails framework components that should be loaded. (Defaults to :active_record, :action_controller, :action_view, :action_mailer, and :active_resource). |
gems | public | RW |
An array of gems that this rails application depends on. Rails will automatically load these gems during
installation, and allow you to install any missing gems with:
rake gems:install You can add gems with the gem method. |
i18n | public | RW | Accessor for i18n settings. |
load_once_paths | public | RW | An array of paths from which Rails will automatically load from only once. All elements of this array must also be in load_paths. |
load_paths | public | RW | An array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list. |
log_level | public | RW | The log level to use for the default Rails logger. In production mode, this defaults to :info. In development mode, it defaults to :debug. |
log_path | public | RW | The path to the log file to use. Defaults to log/#{environment}.log (e.g. log/development.log or log/production.log). |
logger | public | RW | The specific logger to use. By default, a logger will be created and initialized using log_path and log_level, but a programmer may specifically set the logger to use via this accessor and it will be used directly. |
metals | public | RW | The list of metals to load. If this is set to nil, all metals will be loaded in alphabetical order. If this is set to [], no metals will be loaded. Otherwise metals will be loaded in the order specified |
plugin_loader | public | RW | The class that handles loading each plugin. Defaults to Rails::Plugin::Loader, but a sub class would have access to fine grained modification of the loading behavior. See the implementation of Rails::Plugin::Loader for more details. |
plugin_locators | public | RW | The classes that handle finding the desired plugins that you‘d like to load for your application. By default it is the Rails::Plugin::FileSystemLocator which finds plugins to load in vendor/plugins. You can hook into gem location by subclassing Rails::Plugin::Locator and adding it onto the list of plugin_locators. |
plugin_paths | public | RW | The path to the root of the plugins directory. By default, it is in vendor/plugins. |
plugins | public | R | The list of plugins to load. If this is set to nil, all plugins will be loaded. If this is set to [], no plugins will be loaded. Otherwise, plugins will be loaded in the order specified. |
preload_frameworks | public | RW | Whether to preload all frameworks at startup. |
reload_plugins | public | RW |
Enables or disables plugin reloading. You can get around this setting per
plugin. If reload_plugins? is false, add
this to your plugin‘s init.rb to make it reloadable:
ActiveSupport::Dependencies.load_once_paths.delete lib_path If reload_plugins? is true, add this to your plugin‘s init.rb to only load it once: ActiveSupport::Dependencies.load_once_paths << lib_path |
root_path | public | R | The application‘s base directory. |
routes_configuration_file | public | RW | The path to the routes configuration file to use. (Defaults to config/routes.rb.) |
time_zone | public | RW | Sets the default time_zone. Setting this will enable time_zone awareness for Active Record models and set the Active Record default timezone to :utc. |
view_path | public | RW | The root of the application‘s views. (Defaults to app/views.) |
whiny_nils | public | RW | Set to true if you want to be warned (noisily) when you try to invoke any method of nil. Set to false for the standard Ruby behavior. |
Methods
Class
Visibility | Signature |
---|---|
public | new () |
Instance
Visibility | Signature |
---|---|
public | after_initialize (&after_initialize_block) |
public | after_initialize_blocks () |
public | breakpoint_server (_ = nil) |
public | breakpoint_server= (_ = nil) |
public | builtin_directories () |
public | database_configuration () |
public | environment () |
public | environment_path () |
public | framework_paths () |
public | gem (name, options = {}) |
public | middleware () |
public | plugins= (plugins) |
public | reload_plugins? () |
public | set_root_path! () |
public | threadsafe! () |
public | to_prepare (&callback) |
Class Method Detail
new()
Create a new Configuration instance, initialized with the default values.
Instance Method Detail
after_initialize(&after_initialize_block)
Adds a block which will be executed after rails has been fully initialized. Useful for per-environment configuration which depends on the framework being fully initialized.
after_initialize_blocks()
Returns the blocks added with Configuration#after_initialize
breakpoint_server(_ = nil)
Deprecated options:
breakpoint_server=(_ = nil)
Alias for breakpoint_server
builtin_directories()
database_configuration()
Loads and returns the contents of the database_configuration_file. The contents of the file are processed via ERB before being sent through YAML::load.
environment()
Return the currently selected environment. By default, it returns the value of the RAILS_ENV constant.
environment_path()
The path to the current environment‘s file (development.rb, etc.). By default the file is at config/environments/#{environment}.rb.
framework_paths()
gem(name, options = {})
Adds a single Gem dependency to the rails application. By default, it will require the library with the same name as the gem. Use :lib to specify a different name.
# gem 'aws-s3', '>= 0.4.0' # require 'aws/s3' config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', # :source => "http://code.whytheluckystiff.net"
To require a library be installed, but not attempt to load it, pass :lib => false
config.gem 'qrp', :version => '0.4.1', :lib => false
middleware()
plugins=(plugins)
reload_plugins?()
Returns true if plugin reloading is enabled.
set_root_path!()
Set the root_path to RAILS_ROOT and canonicalize it.
threadsafe!()
Enable threaded mode. Allows concurrent requests to controller actions and multiple database connections. Also disables automatic dependency loading after boot, and disables reloading code on every request, as these are fundamentally incompatible with thread safety.
to_prepare(&callback)
Add a preparation callback that will run before every request in development mode, or before the first request in production.
See Dispatcher#to_prepare.