aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gunderloy <MikeG1@larkfarm.com>2009-01-03 06:40:17 -0600
committerMike Gunderloy <MikeG1@larkfarm.com>2009-01-03 06:40:17 -0600
commit0230a3e00289b3a6fbfd2de0bb88da734536a12d (patch)
tree74f9388362a46907e18a570400b166d5442bc6ff
parent884ae7f5e214d35e7205cf5583fde28a44d003f7 (diff)
downloadrails-0230a3e00289b3a6fbfd2de0bb88da734536a12d.tar.gz
rails-0230a3e00289b3a6fbfd2de0bb88da734536a12d.tar.bz2
rails-0230a3e00289b3a6fbfd2de0bb88da734536a12d.zip
Complete draft of configuring guide; add configuring guide to index; regenerate HTML.
-rw-r--r--railties/doc/guides/html/configuring.html168
-rw-r--r--railties/doc/guides/html/index.html5
-rw-r--r--railties/doc/guides/html/layouts_and_rendering.html2
-rw-r--r--railties/doc/guides/source/configuring.txt89
-rw-r--r--railties/doc/guides/source/index.txt6
5 files changed, 198 insertions, 72 deletions
diff --git a/railties/doc/guides/html/configuring.html b/railties/doc/guides/html/configuring.html
index 3497b09ff9..7b7202b2f4 100644
--- a/railties/doc/guides/html/configuring.html
+++ b/railties/doc/guides/html/configuring.html
@@ -205,9 +205,6 @@ ul#navMain {
<a href="#_using_a_preinitializer">Using a Preinitializer</a>
</li>
<li>
- <a href="#_initialization_process_settings">Initialization Process Settings</a>
- </li>
- <li>
<a href="#_configuring_rails_components">Configuring Rails Components</a>
<ul>
@@ -259,26 +256,70 @@ Add additional code to be run at application start time
</p>
</li>
</ul></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<img src="./images/icons/note.png" alt="Note" />
+</td>
+<td class="content">The first edition of this Guide was written from the Rails 2.3 source code. While the information it contains is broadly applicable to Rails 2.2, backwards compatibility is not guaranteed.</td>
+</tr></table>
+</div>
</div>
</div>
<h2 id="_locations_for_initialization_code">1. Locations for Initialization Code</h2>
<div class="sectionbody">
-<div class="paragraph"><p>preinitializers
-environment.rb first
-env-specific files
-initializers (load_application_initializers)
-after-initializer</p></div>
+<div class="paragraph"><p>Rails offers (at least) five good spots to place initialization code:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+Preinitializers
+</p>
+</li>
+<li>
+<p>
+environment.rb
+</p>
+</li>
+<li>
+<p>
+Environment-specific Configuration Files
+</p>
+</li>
+<li>
+<p>
+Initializers (load_application_initializers)
+</p>
+</li>
+<li>
+<p>
+After-Initializers
+</p>
+</li>
+</ul></div>
</div>
<h2 id="_using_a_preinitializer">2. Using a Preinitializer</h2>
<div class="sectionbody">
+<div class="paragraph"><p>Rails allows you to use a preinitializer to run code before the framework itself is loaded. If you save code in <tt>RAILS_ROOT/config/preinitializer.rb</tt>, that code will be the first thing loaded, before any of the framework components (Active Record, Action Pack, and so on.) If you want to change the behavior of one of the classes that is used in the initialization process, you can do so in this file.</p></div>
</div>
-<h2 id="_initialization_process_settings">3. Initialization Process Settings</h2>
-<div class="sectionbody">
-</div>
-<h2 id="_configuring_rails_components">4. Configuring Rails Components</h2>
+<h2 id="_configuring_rails_components">3. Configuring Rails Components</h2>
<div class="sectionbody">
-<h3 id="_configuring_active_record">4.1. Configuring Active Record</h3>
-<div class="paragraph"><p><tt>ActiveRecord::Base</tt> includej a variety of configuration options:</p></div>
+<div class="paragraph"><p>In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The <tt>environment.rb</tt> and environment-specific configuration files (such as <tt>config/environments/production.rb</tt>) allow you to specify the various settings that you want to pass down to all of the components. For example, the default Rails 2.3 <tt>environment.rb</tt> file includes one setting:</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>config<span style="color: #990000">.</span>time_zone <span style="color: #990000">=</span> <span style="color: #FF0000">'UTC'</span></tt></pre></div></div>
+<div class="paragraph"><p>This is a setting for Rails itself. If you want to pass settings to individual Rails components, you can do so via the same <tt>config</tt> object:</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>config<span style="color: #990000">.</span>active_record<span style="color: #990000">.</span>colorize_logging <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span></tt></pre></div></div>
+<div class="paragraph"><p>Rails will use that particular setting to configure Active Record.</p></div>
+<h3 id="_configuring_active_record">3.1. Configuring Active Record</h3>
+<div class="paragraph"><p><tt>ActiveRecord::Base</tt> includes a variety of configuration options:</p></div>
<div class="paragraph"><p><tt>logger</tt> accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed on to any new database connections made. You can retrieve this logger by calling <tt>logger</tt> on either an ActiveRecord model class or an ActiveRecord model instance. Set to nil to disable logging.</p></div>
<div class="paragraph"><p><tt>primary_key_prefix_type</tt> lets you adjust the naming for primary key columns. By default, Rails assumes that primary key columns are named <tt>id</tt> (and this configuration option doesn&#8217;t need to be set.) There are two other choices:</p></div>
<div class="ulist"><ul>
@@ -305,7 +346,7 @@ after-initializer</p></div>
<div class="paragraph"><p><tt>ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans</tt> controls whether ActiveRecord will consider all <tt>tinyint(1)</tt> columns in a MySQL database to be booleans. By default this is <tt>true</tt>.</p></div>
<div class="paragraph"><p>The schema dumper adds one additional configuration option:</p></div>
<div class="paragraph"><p><tt>ActiveRecord::SchemaDumper.ignore_tables</tt> accepts an array of tables that should <em>not</em> be included in any generated schema file. This setting is ignored unless <tt>ActiveRecord::Base.schema_format == :ruby</tt>.</p></div>
-<h3 id="_configuring_action_controller">4.2. Configuring Action Controller</h3>
+<h3 id="_configuring_action_controller">3.2. Configuring Action Controller</h3>
<div class="paragraph"><p>ActionController::Base includes a number of configuration settings:</p></div>
<div class="paragraph"><p><tt>asset_host</tt> provides a string that is prepended to all of the URL-generating helpers in <tt>AssetHelper</tt>. This is designed to allow moving all javascript, CSS, and image files to a separate asset host.</p></div>
<div class="paragraph"><p><tt>consider_all_requests_local</tt> is generally set to <tt>true</tt> during development and <tt>false</tt> during production; if it is set to <tt>true</tt>, then any error will cause detailed debugging information to be dumped in the HTTP response. For finer-grained control, set this to <tt>false</tt> and implement <tt>local_request?</tt> to specify which requests should provide debugging information on errors.</p></div>
@@ -327,7 +368,7 @@ after-initializer</p></div>
<div class="paragraph"><p><tt>ActionController::Dispatcher.error_file_path</tt> gives the path where Rails will look for error files such as <tt>404.html</tt>. The default is <tt>Rails.public_path</tt>.</p></div>
<div class="paragraph"><p>The Active Record session store can also be configured:</p></div>
<div class="paragraph"><p><tt>CGI::Session::ActiveRecordStore::Session.data_column_name</tt> sets the name of the column to use to store session data. By default it is <em>data</em></p></div>
-<h3 id="_configuring_action_view">4.3. Configuring Action View</h3>
+<h3 id="_configuring_action_view">3.3. Configuring Action View</h3>
<div class="paragraph"><p>There are only a few configuration options for Action View, starting with four on <tt>ActionView::Base</tt>:</p></div>
<div class="paragraph"><p><tt>debug_rjs</tt> specifies whether RJS responses should be wrapped in a try/catch block that alert()s the caught exception (and then re-raises it). The default is <tt>false</tt>.</p></div>
<div class="paragraph"><p><tt>warn_cache_misses</tt> tells Rails to display a warning whenever an action results in a cache miss on your view paths. The default is <tt>false</tt>.</p></div>
@@ -335,7 +376,7 @@ after-initializer</p></div>
<div class="paragraph"><p><tt>default_form_builder</tt> tells Rails which form builder to use by default. The default is <tt>ActionView::Helpers::FormBuilder</tt>.</p></div>
<div class="paragraph"><p>The ERB template handler supplies one additional option:</p></div>
<div class="paragraph"><p><tt>ActionView::TemplateHandlers::ERB.erb_trim_mode</tt> gives the trim mode to be used by ERB. It defaults to <tt><em>-</em></tt>. See the <a href="http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/">ERB documentation</a> for more information.</p></div>
-<h3 id="_configuring_action_mailer">4.4. Configuring Action Mailer</h3>
+<h3 id="_configuring_action_mailer">3.4. Configuring Action Mailer</h3>
<div class="paragraph"><p>There are a number of settings available on <tt>ActionMailer::Base</tt>:</p></div>
<div class="paragraph"><p><tt>template_root</tt> gives the root folder for Action Mailer templates.</p></div>
<div class="paragraph"><p><tt>logger</tt> accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Mailer. Set to nil to disable logging.</p></div>
@@ -343,32 +384,32 @@ after-initializer</p></div>
<div class="ulist"><ul>
<li>
<p>
-&lt;tt&gt;:address&lt;/tt&gt; - Allows you to use a remote mail server. Just change it from its default "localhost" setting.
+<tt>:address</tt> - Allows you to use a remote mail server. Just change it from its default "localhost" setting.
</p>
</li>
<li>
<p>
-&lt;tt&gt;:port&lt;/tt&gt; - On the off chance that your mail server doesn&#8217;t run on port 25, you can change it.
+<tt>:port</tt> - On the off chance that your mail server doesn&#8217;t run on port 25, you can change it.
</p>
</li>
<li>
<p>
-&lt;tt&gt;:domain&lt;/tt&gt; - If you need to specify a HELO domain, you can do it here.
+<tt>:domain</tt> - If you need to specify a HELO domain, you can do it here.
</p>
</li>
<li>
<p>
-&lt;tt&gt;:user_name&lt;/tt&gt; - If your mail server requires authentication, set the username in this setting.
+<tt>:user_name</tt> - If your mail server requires authentication, set the username in this setting.
</p>
</li>
<li>
<p>
-&lt;tt&gt;:password&lt;/tt&gt; - If your mail server requires authentication, set the password in this setting.
+<tt>:password</tt> - If your mail server requires authentication, set the password in this setting.
</p>
</li>
<li>
<p>
-&lt;tt&gt;:authentication&lt;/tt&gt; - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of &lt;tt&gt;:plain&lt;/tt&gt;, &lt;tt&gt;:login&lt;/tt&gt;, &lt;tt&gt;:cram_md5&lt;/tt&gt;.
+<tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
</p>
</li>
</ul></div>
@@ -376,66 +417,99 @@ after-initializer</p></div>
<div class="ulist"><ul>
<li>
<p>
-&lt;tt&gt;:location&lt;/tt&gt; - The location of the sendmail executable. Defaults to &lt;tt&gt;/usr/sbin/sendmail&lt;/tt&gt;.
+<tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
</p>
</li>
<li>
<p>
-&lt;tt&gt;:arguments&lt;/tt&gt; - The command line arguments. Defaults to &lt;tt&gt;-i -t&lt;/tt&gt;.
+<tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i -t</tt>.
</p>
</li>
</ul></div>
<div class="paragraph"><p><tt>raise_delivery_errors</tt> specifies whether to raise an error if email delivery cannot be completed. It defaults to <tt>true</tt>.</p></div>
-<div class="paragraph"><p><tt>delivery_method</tt> defines the delivery method. The allowed values are &lt;tt&gt;:smtp&lt;/tt&gt; (default), &lt;tt&gt;:sendmail&lt;/tt&gt;, and &lt;tt&gt;:test&lt;/tt&gt;.</p></div>
+<div class="paragraph"><p><tt>delivery_method</tt> defines the delivery method. The allowed values are <tt>:smtp</tt> (default), <tt>:sendmail</tt>, and <tt>:test</tt>.</p></div>
<div class="paragraph"><p><tt>perform_deliveries</tt> specifies whether mail will actually be delivered. By default this is <tt>true</tt>; it can be convenient to set it to <tt>false</tt> for testing.</p></div>
<div class="paragraph"><p><tt>default_charset</tt> tells Action Mailer which character set to use for the body and for encoding the subject. It defaults to <tt>utf-8</tt>.</p></div>
<div class="paragraph"><p><tt>default_content_type</tt> specifies the default content type used for the main part of the message. It defaults to "text/plain"</p></div>
<div class="paragraph"><p><tt>default_mime_version</tt> is the default MIME version for the message. It defaults to <tt>1.0</tt>.</p></div>
<div class="paragraph"><p><tt>default_implicit_parts_order</tt> - When a message is built implicitly (i.e. multiple parts are assembled from templates
which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to
-&lt;tt&gt;["text/html", "text/enriched", "text/plain"]&lt;/tt&gt;. Items that appear first in the array have higher priority in the mail client
+<tt>["text/html", "text/enriched", "text/plain"]</tt>. Items that appear first in the array have higher priority in the mail client
and appear last in the mime encoded message.</p></div>
-<h3 id="_configuring_active_resource">4.5. Configuring Active Resource</h3>
+<h3 id="_configuring_active_resource">3.5. Configuring Active Resource</h3>
<div class="paragraph"><p>There is a single configuration setting available on <tt>ActiveResource::Base</tt>:</p></div>
<div class="paragraph"><p><tt>logger</tt> accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Active Resource. Set to nil to disable logging.</p></div>
-<h3 id="_configuring_active_support">4.6. Configuring Active Support</h3>
+<h3 id="_configuring_active_support">3.6. Configuring Active Support</h3>
<div class="paragraph"><p>There are a few configuration options available in Active Support:</p></div>
<div class="paragraph"><p><tt>ActiveSupport::BufferedLogger.silencer</tt> is set to <tt>false</tt> to disable the ability to silence logging in a block. The default is <tt>true</tt>.</p></div>
<div class="paragraph"><p><tt>ActiveSupport::Cache::Store.logger</tt> specifies the logger to use within cache store operations.</p></div>
<div class="paragraph"><p><tt>ActiveSupport::Logger.silencer</tt> is set to <tt>false</tt> to disable the ability to silence logging in a block. The default is <tt>true</tt>.</p></div>
-<h3 id="_configuring_active_model">4.7. Configuring Active Model</h3>
+<h3 id="_configuring_active_model">3.7. Configuring Active Model</h3>
<div class="paragraph"><p>Active Model currently has a single configuration setting:</p></div>
-<div class="paragraph"><p>+ActiveModel::Errors.default_error_messages is an array containing all of the validation error messages.</p></div>
+<div class="paragraph"><p><tt>ActiveModel::Errors.default_error_messages</tt> is an array containing all of the validation error messages.</p></div>
</div>
-<h2 id="_using_initializers">5. Using Initializers</h2>
+<h2 id="_using_initializers">4. Using Initializers</h2>
<div class="sectionbody">
-<div class="literalblock">
-<div class="content">
-<pre><tt>organization, controlling load order</tt></pre>
-</div></div>
+<div class="paragraph"><p>After it loads the framework plus any gems and plugins in your application, Rails turns to loading initializers. An initializer is any file of ruby code stored under <tt>/config/initializers</tt> in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and plugins are loaded.</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<img src="./images/icons/note.png" alt="Note" />
+</td>
+<td class="content">You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the <tt>initializers</tt> folder on down.</td>
+</tr></table>
</div>
-<h2 id="_using_an_after_initializer">6. Using an After-Initializer</h2>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<img src="./images/icons/tip.png" alt="Tip" />
+</td>
+<td class="content">If you have any ordering dependency in your initializers, you can control the load order by naming. For example, <tt>01_critical.rb</tt> will be loaded before <tt>02_normal.rb</tt>.</td>
+</tr></table>
+</div>
+</div>
+<h2 id="_using_an_after_initializer">5. Using an After-Initializer</h2>
<div class="sectionbody">
+<div class="paragraph"><p>After-initializers are run (as you might guess) after any initializers are loaded. You can supply an <tt>after_initialize</tt> block (or an array of such blocks) by setting up <tt>config.after_initialize</tt> in any of the Rails configuration files:</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>config<span style="color: #990000">.</span>after_initialize <span style="font-weight: bold"><span style="color: #0000FF">do</span></span>
+ SomeClass<span style="color: #990000">.</span>init
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<img src="./images/icons/warning.png" alt="Warning" />
+</td>
+<td class="content">Some parts of your application, notably observers and routing, are not yet set up at the point where the <tt>after_initialize</tt> block is called.</td>
+</tr></table>
+</div>
</div>
-<h2 id="_rails_environment_settings">7. Rails Environment Settings</h2>
+<h2 id="_rails_environment_settings">6. Rails Environment Settings</h2>
<div class="sectionbody">
-<div class="paragraph"><p>ENV</p></div>
+<div class="paragraph"><p>Some parts of Rails can also be configured externally by supplying environment variables. The following environment variables are recognized by various parts of Rails:</p></div>
+<div class="paragraph"><p><tt>ENV[<em>RAILS_ENV</em>]</tt> defines the Rails environment (production, development, test, and so on) that Rails will run under.</p></div>
+<div class="paragraph"><p><tt>ENV[<em>RAILS_RELATIVE_URL_ROOT</em>]</tt> is used by the routing code to recognize URLs when you deploy your application to a subdirectory.</p></div>
+<div class="paragraph"><p><tt>ENV["RAILS_ASSET_ID"]</tt> will override the default cache-busting timestamps that Rails generates for downloadable assets.</p></div>
+<div class="paragraph"><p><tt>ENV["RAILS_CACHE_ID"]</tt> and <tt>ENV["RAILS_APP_VERSION"]</tt> are used to generate expanded cache keys in Rails' caching code. This allows you to have multiple separate caches from the same application.</p></div>
+<div class="paragraph"><p><tt>ENV[<em>RAILS_GEM_VERSION</em>]</tt> defines the version of the Rails gems to use, if <tt>RAILS_GEM_VERSION</tt> is not defined in your <tt>environment.rb</tt> file.</p></div>
</div>
-<h2 id="_changelog">8. Changelog</h2>
+<h2 id="_changelog">7. Changelog</h2>
<div class="sectionbody">
<div class="paragraph"><p><a href="http://rails.lighthouseapp.com/projects/16213-rails-guides/tickets/28">Lighthouse ticket</a></p></div>
<div class="ulist"><ul>
<li>
<p>
-November 5, 2008: Rough outline by <a href="../authors.html#mgunderloy">Mike Gunderloy</a>
+January 3, 2009: First reasonably complete draft by <a href="../authors.html#mgunderloy">Mike Gunderloy</a>
</p>
-<div class="qlist"><ol>
-<li>
-<p><em>
-need to look for def self. ?
-</em></p>
</li>
-</ol></div>
+<li>
+<p>
+November 5, 2008: Rough outline by <a href="../authors.html#mgunderloy">Mike Gunderloy</a>
+</p>
</li>
</ul></div>
</div>
diff --git a/railties/doc/guides/html/index.html b/railties/doc/guides/html/index.html
index ac192f8cff..38e1b310d7 100644
--- a/railties/doc/guides/html/index.html
+++ b/railties/doc/guides/html/index.html
@@ -377,6 +377,11 @@ of your code.</p></div>
</div>
<div class="paragraph"><p>This guide introduces you to the basic concepts and features of the Rails I18n API and shows you how to localize your application.</p></div>
</div></div>
+<div class="sidebarblock">
+<div class="sidebar-content">
+<div class="sidebar-title"><a href="configuring.html">Configuring Rails Applications</a></div>
+<div class="paragraph"><p>This guide covers the basic configuration settings for a Rails application.</p></div>
+</div></div>
<div class="paragraph"><p>Authors who have contributed to complete guides are listed <a href="authors.html">here</a>.</p></div>
<div class="paragraph"><p>This work is licensed under a <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 License</a></p></div>
</div>
diff --git a/railties/doc/guides/html/layouts_and_rendering.html b/railties/doc/guides/html/layouts_and_rendering.html
index a94c2d4b57..91c3f3350d 100644
--- a/railties/doc/guides/html/layouts_and_rendering.html
+++ b/railties/doc/guides/html/layouts_and_rendering.html
@@ -1404,7 +1404,7 @@ http://www.gnu.org/software/src-highlite -->
<div class="ulist"><ul>
<li>
<p>
-December 27, 2007: Merge patch from Rodrigo Rosenfeld Rosas covering subtemplates
+December 27, 2008: Merge patch from Rodrigo Rosenfeld Rosas covering subtemplates
</p>
</li>
<li>
diff --git a/railties/doc/guides/source/configuring.txt b/railties/doc/guides/source/configuring.txt
index 945e48cd45..489e205eb1 100644
--- a/railties/doc/guides/source/configuring.txt
+++ b/railties/doc/guides/source/configuring.txt
@@ -6,23 +6,43 @@ This guide covers the configuration and initialization features available to Rai
* Adjust the behavior of your Rails applications
* Add additional code to be run at application start time
+NOTE: The first edition of this Guide was written from the Rails 2.3 source code. While the information it contains is broadly applicable to Rails 2.2, backwards compatibility is not guaranteed.
+
== Locations for Initialization Code
-preinitializers
-environment.rb first
-env-specific files
-initializers (load_application_initializers)
-after-initializer
+Rails offers (at least) five good spots to place initialization code:
+
+* Preinitializers
+* environment.rb
+* Environment-specific Configuration Files
+* Initializers (load_application_initializers)
+* After-Initializers
== Using a Preinitializer
-== Initialization Process Settings
+Rails allows you to use a preinitializer to run code before the framework itself is loaded. If you save code in +RAILS_ROOT/config/preinitializer.rb+, that code will be the first thing loaded, before any of the framework components (Active Record, Action Pack, and so on.) If you want to change the behavior of one of the classes that is used in the initialization process, you can do so in this file.
== Configuring Rails Components
+In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The +environment.rb+ and environment-specific configuration files (such as +config/environments/production.rb+) allow you to specify the various settings that you want to pass down to all of the components. For example, the default Rails 2.3 +environment.rb+ file includes one setting:
+
+[source, ruby]
+-------------------------------------------------------
+config.time_zone = 'UTC'
+-------------------------------------------------------
+
+This is a setting for Rails itself. If you want to pass settings to individual Rails components, you can do so via the same +config+ object:
+
+[source, ruby]
+-------------------------------------------------------
+config.active_record.colorize_logging = false
+-------------------------------------------------------
+
+Rails will use that particular setting to configure Active Record.
+
=== Configuring Active Record
-+ActiveRecord::Base+ includej a variety of configuration options:
++ActiveRecord::Base+ includes a variety of configuration options:
+logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed on to any new database connections made. You can retrieve this logger by calling +logger+ on either an ActiveRecord model class or an ActiveRecord model instance. Set to nil to disable logging.
@@ -125,21 +145,21 @@ There are a number of settings available on +ActionMailer::Base+:
+smtp_settings+ allows detailed configuration for the +:smtp+ delivery method. It accepts a hash of options, which can include any of these options:
-* <tt>:address</tt> - Allows you to use a remote mail server. Just change it from its default "localhost" setting.
-* <tt>:port</tt> - On the off chance that your mail server doesn't run on port 25, you can change it.
-* <tt>:domain</tt> - If you need to specify a HELO domain, you can do it here.
-* <tt>:user_name</tt> - If your mail server requires authentication, set the username in this setting.
-* <tt>:password</tt> - If your mail server requires authentication, set the password in this setting.
-* <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
+* +:address+ - Allows you to use a remote mail server. Just change it from its default "localhost" setting.
+* +:port+ - On the off chance that your mail server doesn't run on port 25, you can change it.
+* +:domain+ - If you need to specify a HELO domain, you can do it here.
+* +:user_name+ - If your mail server requires authentication, set the username in this setting.
+* +:password+ - If your mail server requires authentication, set the password in this setting.
+* +:authentication+ - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of +:plain+, +:login+, +:cram_md5+.
+sendmail_settings+ allows detailed configuration for the +sendmail+ delivery method. It accepts a hash of options, which can include any of these options:
-* <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
-* <tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i -t</tt>.
+* +:location+ - The location of the sendmail executable. Defaults to +/usr/sbin/sendmail+.
+* +:arguments+ - The command line arguments. Defaults to +-i -t+.
+raise_delivery_errors+ specifies whether to raise an error if email delivery cannot be completed. It defaults to +true+.
-+delivery_method+ defines the delivery method. The allowed values are <tt>:smtp</tt> (default), <tt>:sendmail</tt>, and <tt>:test</tt>.
++delivery_method+ defines the delivery method. The allowed values are +:smtp+ (default), +:sendmail+, and +:test+.
+perform_deliveries+ specifies whether mail will actually be delivered. By default this is +true+; it can be convenient to set it to +false+ for testing.
@@ -151,7 +171,7 @@ There are a number of settings available on +ActionMailer::Base+:
+default_implicit_parts_order+ - When a message is built implicitly (i.e. multiple parts are assembled from templates
which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to
-<tt>["text/html", "text/enriched", "text/plain"]</tt>. Items that appear first in the array have higher priority in the mail client
++["text/html", "text/enriched", "text/plain"]+. Items that appear first in the array have higher priority in the mail client
and appear last in the mime encoded message.
=== Configuring Active Resource
@@ -174,21 +194,46 @@ There are a few configuration options available in Active Support:
Active Model currently has a single configuration setting:
-+ActiveModel::Errors.default_error_messages is an array containing all of the validation error messages.
++ActiveModel::Errors.default_error_messages+ is an array containing all of the validation error messages.
== Using Initializers
- organization, controlling load order
+
+After it loads the framework plus any gems and plugins in your application, Rails turns to loading initializers. An initializer is any file of ruby code stored under +/config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and plugins are loaded.
+
+NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the +initializers+ folder on down.
+
+TIP: If you have any ordering dependency in your initializers, you can control the load order by naming. For example, +01_critical.rb+ will be loaded before +02_normal.rb+.
== Using an After-Initializer
+After-initializers are run (as you might guess) after any initializers are loaded. You can supply an +after_initialize+ block (or an array of such blocks) by setting up +config.after_initialize+ in any of the Rails configuration files:
+
+[source, ruby]
+------------------------------------------------------------------
+config.after_initialize do
+ SomeClass.init
+end
+------------------------------------------------------------------
+
+WARNING: Some parts of your application, notably observers and routing, are not yet set up at the point where the +after_initialize+ block is called.
+
== Rails Environment Settings
-ENV
+Some parts of Rails can also be configured externally by supplying environment variables. The following environment variables are recognized by various parts of Rails:
+
++ENV['RAILS_ENV']+ defines the Rails environment (production, development, test, and so on) that Rails will run under.
+
++ENV['RAILS_RELATIVE_URL_ROOT']+ is used by the routing code to recognize URLs when you deploy your application to a subdirectory.
+
++ENV["RAILS_ASSET_ID"]+ will override the default cache-busting timestamps that Rails generates for downloadable assets.
+
++ENV["RAILS_CACHE_ID"]+ and +ENV["RAILS_APP_VERSION"]+ are used to generate expanded cache keys in Rails' caching code. This allows you to have multiple separate caches from the same application.
+
++ENV['RAILS_GEM_VERSION']+ defines the version of the Rails gems to use, if +RAILS_GEM_VERSION+ is not defined in your +environment.rb+ file.
== Changelog ==
http://rails.lighthouseapp.com/projects/16213-rails-guides/tickets/28[Lighthouse ticket]
+* January 3, 2009: First reasonably complete draft by link:../authors.html#mgunderloy[Mike Gunderloy]
* November 5, 2008: Rough outline by link:../authors.html#mgunderloy[Mike Gunderloy]
-
-need to look for def self. ???
diff --git a/railties/doc/guides/source/index.txt b/railties/doc/guides/source/index.txt
index 174267d630..cd536873e7 100644
--- a/railties/doc/guides/source/index.txt
+++ b/railties/doc/guides/source/index.txt
@@ -132,8 +132,10 @@ CAUTION: still a basic draft
This guide introduces you to the basic concepts and features of the Rails I18n API and shows you how to localize your application.
***********************************************************
-
-
+.link:configuring.html[Configuring Rails Applications]
+***********************************************************
+This guide covers the basic configuration settings for a Rails application.
+***********************************************************
Authors who have contributed to complete guides are listed link:authors.html[here].