Configuring Rails Environments: The Cheat Sheet

Posted by kev Mon, 22 May 2006 08:24:00 GMT

These are options allowed by Rails::Configuration in Rails 1.1.2. This list is generally exhaustive (and often taken directly from the documentation), but more detailed documentation can be found in the source code itself where these options are found as class accessor methods (cattr_accessor).

Update: If you like it, digg it.

Update 2: Also see my Guide to Environments in Rails 1.1 for information on how specific configurations work.

General Options

For more detailed documentation, see the source code directly. Each of these options should be prepended with config. when used with a Rails::Initializer do |config| block.

Whether or not to use the breakpoint server (boolean)
Whether or not classes should be cached (set to false if you want application classes to be reloaded on each request)
The list of connection adapters to load.
By default, all connection adapters are loaded. You can set this to be just the adapter(s) you will use to reduce your application’s load time.
The list of paths that should be searched for controllers.
Defaults to app/controllers and components.
The path to the database configuration file to use.
Defaults to config/database.yml.
The list of rails framework components that should be loaded.
Defaults to :active_record, :action_controller, :action_view, :action_mailer, and :action_web_service.
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.
The log level to use for the default Rails logger.
In production mode, this defaults to :info. In development mode, it defaults to :debug.
The path to the log file to use.
Defaults to log/#{environment}.log (e.g. log/development.log or log/production.log).
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.
The root of the application’s views.
Defaults to app/views.
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.
The path to the root of the plugins directory.
By default, it is in vendor/plugins.

ActiveRecord Options

Each of these options should be prepended with config.active_record. when used with a Rails::Initializer do |config| block.

Accessor for the prefix type that will be prepended to every primary key column name. The options are :table_name and :table_name_with_underscore. If the first is specified, the Product class will look for “productid” instead of “id” as the primary column. If the latter is specified, the Product class will look for “product_id” instead of “id”. Remember that this is a global setting for all Active Records.
The string to prepend to every table name.
By default, the prefix is an empty string
The same as table_name_prefix, but it appends the string to the table name.
Indicates whether or not table names should be the pluralized versions of the corresponding class names.
Defaults to true.
Should logs have ANSI color codes in logging statments?
Defaults to true
Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates and times from the database.
Defaults to :local by default.
Determines whether or not to use a connection for each thread, or a single shared connection for all threads.
Defaults to false. Set to true if you’re writing a threaded application.
Determines whether to speed up access by generating optimized reader methods to avoid expensive calls to method_missing when accessing attributes by name. You might want to set this to false in development mode, because the methods would be regenerated on each request.
Specifies whether to dump the database in ruby or sql. It takes :ruby or :sql as options, and defaults to :ruby

ActionController Options

Each of these options should be prepended with config.action_controller. when used with a Rails::Initializer do |config| block.

Determines whether the view has access to controller internals @request, @response, @session, and @template.
Prepends all the URL-generating helpers from AssetHelper (eg. image_tag)
All requests are considered local by default (true), so everyone will be exposed to detailed debugging screens on errors.
Defaults to true
Enable or disable the collection of failure information for RoutingErrors.
Defaults to true.
Controls whether the application is thread-safe.
Defaults to false.
Lets you register handlers wich will process the http body and add parameters to the @params hash.
Defaults to { Mime::XML => :xml_simple }
Sets the default template location. For example, a call to render("test/template") will be converted to "#{template_root}/test/template.rhtml"
Can be set to nil for no logging or a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class.
Turn on ignore_missing_templates if you want to unit test actions without making the associated templates.

ActionView Options

Each of these options should be prepended with config.action_view. when used with a Rails::Initializer do |config| block.

Specify whether file modification times should be checked to see if a template needs recompilation
Specify whether file extension lookup should be cached. Should be false for development environments.
Defaults to true.
Specify whether local_assigns should be able to use string keys.
Defaults to true.
String keys are deprecated and will be removed shortly.
Specify whether RJS responses should be wrapped in a try/catch block that alert()s the caught exception (and then re-raises it).
Defaults to false.
Can be set to nil for no logging or a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class.

ActionMailer Options

Each of these options should be prepended with config.action_mailer. when used with a Rails::Initializer do |config| block.

A hash defining the server to be used for email.
Defaults to using a server localy on port 25 as such:
{ :address        => "localhost", 
  :port           => 25, 
  :domain         => 'localhost.localdomain', 
  :user_name      => nil, 
  :password       => nil, 
  :authentication => nil }
Defaults to true
Defaults to :smtp
Defaults to true
Defaults to “utf-8”
Defaults to “text/plain”
Defaults to nil
Defaults to [ “text/html”, “text/enriched”, “text/plain” ]

Posted in , ,

Comments are disabled