Skip to content
This repository
Browse code

Merge docrails

  • Loading branch information...
commit 886124e688de7b48f32925eca42e4185e487ec84 1 parent 3be0ad6
Pratik lifo authored

Showing 31 changed files with 4,704 additions and 952 deletions. Show diff stats Hide diff stats

  1. +5 4 activerecord/lib/active_record/associations.rb
  2. +9 4 activesupport/lib/active_support/core_ext/try.rb
  3. +2 2 railties/Rakefile
  4. +5 0 railties/doc/guides/html/2_2_release_notes.html
  5. +1,033 0 railties/doc/guides/html/2_3_release_notes.html
  6. +570 28 railties/doc/guides/html/action_mailer_basics.html
  7. +48 4 railties/doc/guides/html/actioncontroller_basics.html
  8. +342 0 railties/doc/guides/html/active_record_basics.html
  9. +7 25 railties/doc/guides/html/creating_plugins.html
  10. +254 241 railties/doc/guides/html/form_helpers.html
  11. +162 63 railties/doc/guides/html/getting_started_with_rails.html
  12. +495 79 railties/doc/guides/html/i18n.html
  13. +5 5 railties/doc/guides/html/index.html
  14. +2 1  railties/doc/guides/source/2_2_release_notes.txt
  15. +514 0 railties/doc/guides/source/2_3_release_notes.txt
  16. +372 22 railties/doc/guides/source/action_mailer_basics.txt
  17. +36 3 railties/doc/guides/source/actioncontroller_basics/http_auth.txt
  18. +106 119 railties/doc/guides/source/active_record_basics.txt
  19. +1 1  railties/doc/guides/source/creating_plugins/appendix.txt
  20. +4 0 railties/doc/guides/source/creating_plugins/creating_plugins/lib/main.rb
  21. +1 1  railties/doc/guides/source/creating_plugins/generator_commands.txt
  22. +2 21 railties/doc/guides/source/creating_plugins/migrations.txt
  23. +1 1  railties/doc/guides/source/creating_plugins/models.txt
  24. +2 2 railties/doc/guides/source/creating_plugins/tasks.txt
  25. +0 3  railties/doc/guides/source/creating_plugins/test_setup.txt
  26. +232 207 railties/doc/guides/source/form_helpers.txt
  27. +125 29 railties/doc/guides/source/getting_started_with_rails.txt
  28. +361 79 railties/doc/guides/source/i18n.txt
  29. BIN  railties/doc/guides/source/images/posts_index.png
  30. BIN  railties/doc/guides/source/images/rails_welcome.png
  31. +8 8 railties/doc/guides/source/index.txt
9 activerecord/lib/active_record/associations.rb
@@ -1166,11 +1166,12 @@ def belongs_to(association_id, options = {})
1166 1166 # [:foreign_key]
1167 1167 # Specify the foreign key used for the association. By default this is guessed to be the name
1168 1168 # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_and_belongs_to_many+ association
1169   - # will use "person_id" as the default <tt>:foreign_key</tt>.
  1169 + # to Project will use "person_id" as the default <tt>:foreign_key</tt>.
1170 1170 # [:association_foreign_key]
1171   - # Specify the association foreign key used for the association. By default this is
1172   - # guessed to be the name of the associated class in lower-case and "_id" suffixed. So if the associated class is Project,
1173   - # the +has_and_belongs_to_many+ association will use "project_id" as the default <tt>:association_foreign_key</tt>.
  1171 + # Specify the foreign key used for the association on the receiving side of the association.
  1172 + # By default this is guessed to be the name of the associated class in lower-case and "_id" suffixed.
  1173 + # So if a Person class makes a +has_and_belongs_to_many+ association to Project,
  1174 + # the association will use "project_id" as the default <tt>:association_foreign_key</tt>.
1174 1175 # [:conditions]
1175 1176 # Specify the conditions that the associated object must meet in order to be included as a +WHERE+
1176 1177 # SQL fragment, such as <tt>authorized = 1</tt>. Record creations from the association are scoped if a hash is used.
13 activesupport/lib/active_support/core_ext/try.rb
... ... @@ -1,6 +1,9 @@
1 1 class Object
2   - # Tries to send the method only if object responds to it. Return +nil+ otherwise.
3   - # It will also forward any arguments and/or block like Object#send does.
  2 + # Invokes the method identified by the symbol +method+, passing it any arguments
  3 + # and/or the block specified, just like the regular Ruby <tt>Object#send</tt> does.
  4 + #
  5 + # *Unlike* that method however, a +NoMethodError+ exception will *not* be raised
  6 + # and +nil+ will be returned instead, if the receiving object is a +nil+ object or NilClass.
4 7 #
5 8 # ==== Examples
6 9 #
@@ -12,11 +15,13 @@ class Object
12 15 # With try
13 16 # @person.try(:name)
14 17 #
15   - # Try also accepts arguments/blocks for the method it is trying
  18 + # +try+ also accepts arguments and/or a block, for the method it is trying
16 19 # Person.try(:find, 1)
17 20 # @people.try(:collect) {|p| p.name}
18 21 #--
19   - # This method def is for rdoc only. The alias_method below overrides it as an optimization.
  22 + # This method definition below is for rdoc purposes only. The alias_method call
  23 + # below overrides it as an optimization since +try+ behaves like +Object#send+,
  24 + # unless called on +NilClass+.
20 25 def try(method, *args, &block)
21 26 send(method, *args, &block)
22 27 end
4 railties/Rakefile
@@ -285,7 +285,7 @@ task :guides do
285 285 asciidoc_conf = 'doc/guides/asciidoc.conf'
286 286
287 287 ignore = ['..', 'icons', 'images', 'templates', 'stylesheets']
288   - ignore << 'active_record_basics.txt'
  288 + #ignore << 'active_record_basics.txt'
289 289
290 290 indexless = ['index.txt', 'authors.txt']
291 291
@@ -301,7 +301,7 @@ task :guides do
301 301 end
302 302
303 303 entries.each do |entry|
304   - next if ignore.include?(entry)
  304 + next if ignore.include?(entry) or entry =~ /^\./ # because Vim is always saving hidden swap files
305 305
306 306 if File.directory?(File.join(source, entry))
307 307 # If the current entry is a directory, then we will want to compile
5 railties/doc/guides/html/2_2_release_notes.html
@@ -993,6 +993,11 @@ <h2 id="_deprecated">11. Deprecated</h2>
993 993 Durations of fractional months or fractional years are deprecated. Use Ruby&#8217;s core <tt>Date</tt> and <tt>Time</tt> class arithmetic instead.
994 994 </p>
995 995 </li>
  996 +<li>
  997 +<p>
  998 +<tt>Request#relative_url_root</tt> is deprecated. Use <tt>ActionController::Base.relative_url_root</tt> instead.
  999 +</p>
  1000 +</li>
996 1001 </ul></div>
997 1002 </div>
998 1003 <h2 id="_credits">12. Credits</h2>
1,033 railties/doc/guides/html/2_3_release_notes.html
... ... @@ -0,0 +1,1033 @@
  1 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2 +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  3 +<head>
  4 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5 + <title>Ruby on Rails 2.3 Release Notes</title>
  6 + <!--[if lt IE 8]>
  7 + <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js" type="text/javascript"></script>
  8 + <![endif]-->
  9 + <link href="stylesheets/base.css" media="screen" rel="Stylesheet" type="text/css" />
  10 + <link href="stylesheets/forms.css" media="screen" rel="Stylesheet" type="text/css" />
  11 + <link href="stylesheets/more.css" media="screen" rel="Stylesheet" type="text/css" />
  12 +</head>
  13 +<body>
  14 + <div id="header" >
  15 + <div id="logo">
  16 + <a href="index.html" title="Ruby on Rails"><img src="images/rails_logo_remix.gif" alt="Rails" height="140" width="110" /></a>
  17 + </div>
  18 +
  19 + <h1 id="site_title"><span>Ruby on Rails</span></h1>
  20 + <h2 id="site_title_tagline">Sustainable productivity for web-application development</h2>
  21 +
  22 + <ul id="navMain">
  23 + <li class="first-child"><a href="http://www.rubyonrails.org/" title="Ruby on Rails" class="ruby_on_rails">Ruby on Rails</a></li>
  24 + <li><a class="manuals" href="index.html" title="Manuals Index">Guides Index</a></li>
  25 + </ul>
  26 + </div>
  27 +
  28 + <div id="container">
  29 +
  30 + <div id="sidebar">
  31 + <h2>Chapters</h2>
  32 + <ol>
  33 + <li>
  34 + <a href="#_application_architecture">Application Architecture</a>
  35 + <ul>
  36 +
  37 + <li><a href="#_rack_integration">Rack Integration</a></li>
  38 +
  39 + <li><a href="#_renewed_support_for_rails_engines">Renewed Support for Rails Engines</a></li>
  40 +
  41 + </ul>
  42 + </li>
  43 + <li>
  44 + <a href="#_documentation">Documentation</a>
  45 + </li>
  46 + <li>
  47 + <a href="#_active_record">Active Record</a>
  48 + <ul>
  49 +
  50 + <li><a href="#_nested_attributes">Nested Attributes</a></li>
  51 +
  52 + <li><a href="#_nested_transactions">Nested Transactions</a></li>
  53 +
  54 + <li><a href="#_dynamic_scopes">Dynamic Scopes</a></li>
  55 +
  56 + <li><a href="#_default_scopes">Default Scopes</a></li>
  57 +
  58 + <li><a href="#_multiple_conditions_for_callbacks">Multiple Conditions for Callbacks</a></li>
  59 +
  60 + <li><a href="#_find_with_having">Find with having</a></li>
  61 +
  62 + <li><a href="#_hash_conditions_for_tt_has_many_tt_relationships">Hash Conditions for <tt>has_many</tt> relationships</a></li>
  63 +
  64 + <li><a href="#_reconnecting_mysql_connections">Reconnecting MySQL Connections</a></li>
  65 +
  66 + <li><a href="#_other_active_record_changes">Other Active Record Changes</a></li>
  67 +
  68 + </ul>
  69 + </li>
  70 + <li>
  71 + <a href="#_action_controller">Action Controller</a>
  72 + <ul>
  73 +
  74 + <li><a href="#_unified_rendering">Unified Rendering</a></li>
  75 +
  76 + <li><a href="#_application_controller_renamed">Application Controller Renamed</a></li>
  77 +
  78 + <li><a href="#_http_digest_authentication_support">HTTP Digest Authentication Support</a></li>
  79 +
  80 + <li><a href="#_more_efficient_routing">More Efficient Routing</a></li>
  81 +
  82 + <li><a href="#_rack_based_lazy_loaded_sessions">Rack-based Lazy-loaded Sessions</a></li>
  83 +
  84 + <li><a href="#_mime_type_handling_changes">MIME Type Handling Changes</a></li>
  85 +
  86 + <li><a href="#_optimization_of_tt_respond_to_tt">Optimization of <tt>respond_to</tt></a></li>
  87 +
  88 + <li><a href="#_improved_caching_performance">Improved Caching Performance</a></li>
  89 +
  90 + <li><a href="#_localized_views">Localized Views</a></li>
  91 +
  92 + <li><a href="#_other_action_controller_changes">Other Action Controller Changes</a></li>
  93 +
  94 + </ul>
  95 + </li>
  96 + <li>
  97 + <a href="#_action_view">Action View</a>
  98 + <ul>
  99 +
  100 + <li><a href="#_nested_object_forms">Nested Object Forms</a></li>
  101 +
  102 + <li><a href="#_smart_rendering_of_partials">Smart Rendering of Partials</a></li>
  103 +
  104 + <li><a href="#_prompts_for_date_select_helpers">Prompts for Date Select Helpers</a></li>
  105 +
  106 + <li><a href="#_assettag_timestamp_caching">AssetTag Timestamp Caching</a></li>
  107 +
  108 + <li><a href="#_asset_hosts_as_objects">Asset Hosts as Objects</a></li>
  109 +
  110 + <li><a href="#_grouped_options_for_select_helper_method">grouped_options_for_select Helper Method</a></li>
  111 +
  112 + <li><a href="#_other_action_view_changes">Other Action View Changes</a></li>
  113 +
  114 + </ul>
  115 + </li>
  116 + <li>
  117 + <a href="#_active_support">Active Support</a>
  118 + <ul>
  119 +
  120 + <li><a href="#_object_try">Object#try</a></li>
  121 +
  122 + <li><a href="#_object_tap_backport">Object#tap Backport</a></li>
  123 +
  124 + <li><a href="#_fractional_seconds_for_timewithzone">Fractional seconds for TimeWithZone</a></li>
  125 +
  126 + <li><a href="#_json_key_quoting">JSON Key Quoting</a></li>
  127 +
  128 + <li><a href="#_other_active_support_changes">Other Active Support Changes</a></li>
  129 +
  130 + </ul>
  131 + </li>
  132 + <li>
  133 + <a href="#_railties">Railties</a>
  134 + <ul>
  135 +
  136 + <li><a href="#_rails_metal">Rails Metal</a></li>
  137 +
  138 + <li><a href="#_application_templates">Application Templates</a></li>
  139 +
  140 + <li><a href="#_quieter_backtraces">Quieter Backtraces</a></li>
  141 +
  142 + <li><a href="#_faster_boot_time_in_development_mode_with_lazy_loading_autoload">Faster Boot Time in Development Mode with Lazy Loading/Autoload</a></li>
  143 +
  144 + <li><a href="#_other_railties_changes">Other Railties Changes</a></li>
  145 +
  146 + </ul>
  147 + </li>
  148 + <li>
  149 + <a href="#_deprecated">Deprecated</a>
  150 + </li>
  151 + <li>
  152 + <a href="#_credits">Credits</a>
  153 + </li>
  154 + </ol>
  155 + </div>
  156 +
  157 + <div id="content">
  158 + <h1>Ruby on Rails 2.3 Release Notes</h1>
  159 + <div id="preamble">
  160 +<div class="sectionbody">
  161 +<div class="paragraph"><p>Rails 2.3 delivers a variety of new and improved features, including pervasive Rack integration, refreshed support for Rails Engines, nested transactions for Active Record, dynamic and default scopes, unified rendering, more efficient routing, application templates, and quiet backtraces. This list covers the major upgrades, but doesn&#8217;t include every little bug fix and change. If you want to see everything, check out the <a href="http://github.com/rails/rails/commits/master">list of commits</a> in the main Rails repository on GitHub or review the <tt>CHANGELOG</tt> files for the individual Rails components.</p></div>
  162 +</div>
  163 +</div>
  164 +<h2 id="_application_architecture">1. Application Architecture</h2>
  165 +<div class="sectionbody">
  166 +<div class="paragraph"><p>There are two major changes in the architecture of Rails applications: complete integration of the <a href="http://rack.rubyforge.org/">Rack</a> modular web server interface, and renewed support for Rails Engines.</p></div>
  167 +<h3 id="_rack_integration">1.1. Rack Integration</h3>
  168 +<div class="paragraph"><p>Rails has now broken with its CGI past, and uses Rack everywhere. This required and resulted in a tremendous number of internal changes (but if you use CGI, don&#8217;t worry; Rails now supports CGI through a proxy interface.) Still, this is a major change to Rails internals. After upgrading to 2.3, you should test on your local environment and your production environment. Some things to test:</p></div>
  169 +<div class="ulist"><ul>
  170 +<li>
  171 +<p>
  172 +Sessions
  173 +</p>
  174 +</li>
  175 +<li>
  176 +<p>
  177 +Cookies
  178 +</p>
  179 +</li>
  180 +<li>
  181 +<p>
  182 +File uploads
  183 +</p>
  184 +</li>
  185 +<li>
  186 +<p>
  187 +JSON/XML APIs
  188 +</p>
  189 +</li>
  190 +</ul></div>
  191 +<div class="paragraph"><p>Here&#8217;s a summary of the rack-related changes:</p></div>
  192 +<div class="ulist"><ul>
  193 +<li>
  194 +<p>
  195 +<tt>script/server</tt> has been switched to use Rack, which means it supports any Rack compatible server. <tt>script/server</tt> will also pick up a rackup configuration file if one exists. By default, it will look for a <tt>config.ru</tt> file, but you can override this with the <tt>-c</tt> switch.
  196 +</p>
  197 +</li>
  198 +<li>
  199 +<p>
  200 +The FCGI handler goes through Rack
  201 +</p>
  202 +</li>
  203 +<li>
  204 +<p>
  205 +<tt>ActionController::Dispatcher</tt> maintains its own default middleware stack. Middlewares can be injected in, reordered, and removed. The stack is compiled into a chain on boot. You can configure the middleware stack in <tt>environment.rb</tt>
  206 +</p>
  207 +</li>
  208 +<li>
  209 +<p>
  210 +The <tt>rake middleware</tt> task has been added to inspect the middleware stack. This is useful for debugging the order of the middleware stack.
  211 +</p>
  212 +</li>
  213 +<li>
  214 +<p>
  215 +The integration test runner has been modified to execute the entire middleware and application stack. This makes integration tests perfect for testing Rack middleware.
  216 +</p>
  217 +</li>
  218 +<li>
  219 +<p>
  220 +<tt>ActionController::CGIHandler</tt> is a backwards compatible CGI wrapper around Rack. The <tt>CGIHandler</tt> is meant to take an old CGI object and converts its environment information into a Rack compatible form.
  221 +</p>
  222 +</li>
  223 +<li>
  224 +<p>
  225 +<tt>CgiRequest</tt> and <tt>CgiResponse</tt> have been removed
  226 +</p>
  227 +</li>
  228 +<li>
  229 +<p>
  230 +Session stores are now lazy loaded. If you never access the session object during a request, it will never attempt to load the session data (parse the cookie, load the data from memcache, or lookup an Active Record object).
  231 +</p>
  232 +</li>
  233 +<li>
  234 +<p>
  235 +<tt>CGI::Session::CookieStore</tt> has been replaced by <tt>ActionController::Session::CookieStore</tt>
  236 +</p>
  237 +</li>
  238 +<li>
  239 +<p>
  240 +<tt>CGI::Session::MemCacheStore</tt> has been replaced by <tt>ActionController::Session::MemCacheStore</tt>
  241 +</p>
  242 +</li>
  243 +<li>
  244 +<p>
  245 +<tt>CGI::Session::ActiveRecordStore</tt> has been replaced by <tt>ActiveRecord::SessionStore</tt>
  246 +</p>
  247 +</li>
  248 +<li>
  249 +<p>
  250 +You can still change your session store with <tt>ActionController::Base.session_store = :active_record_store</tt>
  251 +</p>
  252 +</li>
  253 +<li>
  254 +<p>
  255 +Default sessions options are still set with <tt>ActionController::Base.session = { :key =&gt; "..." }</tt>
  256 +</p>
  257 +</li>
  258 +<li>
  259 +<p>
  260 +The mutex that normally wraps your entire request has been moved into middleware, <tt>ActionController::Lock</tt>
  261 +</p>
  262 +</li>
  263 +<li>
  264 +<p>
  265 +<tt>ActionController::AbstractRequest</tt> and <tt>ActionController::Request</tt> have been unified. The new <tt>ActionController::Request</tt> inherits from <tt>Rack::Request</tt>. This affects access to <tt>response.headers[<em>type</em>]</tt> in test requests. Use <tt>response.content_type</tt> instead.
  266 +</p>
  267 +</li>
  268 +<li>
  269 +<p>
  270 +<tt>ActiveRecord::QueryCache</tt> middleware is automatically inserted onto the middleware stack if <tt>ActiveRecord</tt> has been loaded. This middleware sets up and flushes the per-request Active Record query cache.
  271 +</p>
  272 +</li>
  273 +<li>
  274 +<p>
  275 +The Rails router and controller classes follow the Rack spec. You can call a controller directly with <tt>SomeController.call(env)</tt>. The router stores the routing parameters in <tt>rack.routing_args</tt>.
  276 +</p>
  277 +</li>
  278 +<li>
  279 +<p>
  280 +<tt>ActionController::Request</tt> inherits from <tt>Rack::Request</tt>
  281 +</p>
  282 +</li>
  283 +<li>
  284 +<p>
  285 +Instead of <tt>config.action_controller.session = { :session_key =&gt; <em>foo</em>, ...</tt> use <tt>config.action_controller.session = { :key =&gt; <em>foo</em>, ...</tt>
  286 +</p>
  287 +</li>
  288 +<li>
  289 +<p>
  290 +Using the <tt>ParamsParser</tt> middleware preprocesses any XML, JSON, or YAML requests so they can be read normally with any <tt>Rack::Request</tt> object after it.
  291 +</p>
  292 +</li>
  293 +</ul></div>
  294 +<h3 id="_renewed_support_for_rails_engines">1.2. Renewed Support for Rails Engines</h3>
  295 +<div class="paragraph"><p>After some versions without an upgrade, Rails 2.3 offers some new features for Rails Engines (Rails applications that can be embedded within other applications). First, routing files in engines are automatically loaded and reloaded now, just like your <tt>routes.rb</tt> file (this also applies to routing files in other plugins). Second, if your plugin has an app folder, then app/[models|controllers|helpers] will automatically be added to the Rails load path. Engines also support adding view paths now.</p></div>
  296 +</div>
  297 +<h2 id="_documentation">2. Documentation</h2>
  298 +<div class="sectionbody">
  299 +<div class="paragraph"><p>The <a href="http://guides.rubyonrails.org/">Ruby on Rails guides</a> project has published several additional guides for Rails 2.3. In addition, a <a href="http://guides.rails.info/">separate site</a> maintains updated copies of the Guides for Edge Rails. Other documentation efforts include a relaunch of the <a href="http://newwiki.rubyonrails.org/">Rails wiki</a> and early planning for a Rails Book.</p></div>
  300 +<div class="ulist"><ul>
  301 +<li>
  302 +<p>
  303 +More Information: <a href="http://weblog.rubyonrails.org/2009/1/15/rails-documentation-projects">Rails Documentation Projects</a>
  304 +</p>
  305 +</li>
  306 +</ul></div>
  307 +</div>
  308 +<h2 id="_active_record">3. Active Record</h2>
  309 +<div class="sectionbody">
  310 +<div class="paragraph"><p>Active Record gets quite a number of new features and bug fixes in Rails 2.3. The highlights include nested attributes, nested transactions, dynamic scopes, and default scopes.</p></div>
  311 +<h3 id="_nested_attributes">3.1. Nested Attributes</h3>
  312 +<div class="paragraph"><p>Active Record can now update the attributes on nested models directly, provided you tell it to do so:</p></div>
  313 +<div class="listingblock">
  314 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  315 +by Lorenzo Bettini
  316 +http://www.lorenzobettini.it
  317 +http://www.gnu.org/software/src-highlite -->
  318 +<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> Book <span style="color: #990000">&lt;</span> ActiveRecord<span style="color: #990000">::</span>Base
  319 + has_one <span style="color: #990000">:</span>author
  320 + has_many <span style="color: #990000">:</span>pages
  321 +
  322 + accepts_nested_attributes_for <span style="color: #990000">:</span>author<span style="color: #990000">,</span> <span style="color: #990000">:</span>pages
  323 +<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
  324 +<div class="paragraph"><p>Turning on nested attributes enables a number of things: automatic (and atomic) saving of a record together with its associated children, child-aware validations, and support for nested forms (discussed later).</p></div>
  325 +<div class="ulist"><ul>
  326 +<li>
  327 +<p>
  328 +Lead Contributor: link_to:<a href="http://www.superalloy.nl/blog/">Eloy Duran</a>
  329 +</p>
  330 +</li>
  331 +<li>
  332 +<p>
  333 +More Information: link_to:<a href="http://weblog.rubyonrails.org/2009/1/26/nested-model-forms">Nested Model Forms</a>
  334 +</p>
  335 +</li>
  336 +</ul></div>
  337 +<h3 id="_nested_transactions">3.2. Nested Transactions</h3>
  338 +<div class="paragraph"><p>Active Record now supports nested transactions, a much-requested feature. Now you can write code like this:</p></div>
  339 +<div class="listingblock">
  340 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  341 +by Lorenzo Bettini
  342 +http://www.lorenzobettini.it
  343 +http://www.gnu.org/software/src-highlite -->
  344 +<pre><tt>User<span style="color: #990000">.</span>transaction <span style="font-weight: bold"><span style="color: #0000FF">do</span></span>
  345 + User<span style="color: #990000">.</span>create<span style="color: #990000">(:</span>username <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'Admin'</span><span style="color: #990000">)</span>
  346 + User<span style="color: #990000">.</span>transaction<span style="color: #990000">(:</span>requires_new <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span>
  347 + User<span style="color: #990000">.</span>create<span style="color: #990000">(:</span>username <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'Regular'</span><span style="color: #990000">)</span>
  348 + <span style="font-weight: bold"><span style="color: #0000FF">raise</span></span> ActiveRecord<span style="color: #990000">::</span>Rollback
  349 + <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
  350 + <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
  351 +
  352 + User<span style="color: #990000">.</span>find<span style="color: #990000">(:</span>all<span style="color: #990000">)</span> <span style="font-style: italic"><span style="color: #9A1900"># =&gt; Returns only Admin</span></span></tt></pre></div></div>
  353 +<div class="paragraph"><p>Nested transactions let you roll back an inner transaction without affecting the state of the outer transaction. If you want a transaction to be nested, you must explicitly add the <tt>:requires_new</tt> option; otherwise, a nested transaction simply becomes part of the parent transaction (as it does currently on Rails 2.2). Under the covers, nested transactions are <a href="http://rails.lighthouseapp.com/projects/8994/tickets/383">using savepoints</a>, so they&#8217;re supported even on databases that don&#8217;t have true nested transactions. There is also a bit of magic going on to make these transactions play well with transactional fixtures during testing.</p></div>
  354 +<div class="ulist"><ul>
  355 +<li>
  356 +<p>
  357 +Lead Contributors: <a href="http://www.workingwithrails.com/person/4985-jonathan-viney">Jonathan Viney</a> and <a href="http://izumi.plan99.net/blog/">Hongli Lai</a>
  358 +</p>
  359 +</li>
  360 +</ul></div>
  361 +<h3 id="_dynamic_scopes">3.3. Dynamic Scopes</h3>
  362 +<div class="paragraph"><p>You know about dynamic finders in Rails (which allow you to concoct methods like <tt>find_by_color_and_flavor</tt> on the fly) and named scopes (which allow you to encapsulate reusable query conditions into friendly names like <tt>currently_active</tt>). Well, now you can have dynamic scope methods. The idea is to put together syntax that allows filtering on the fly <em>and</em> method chaining. For example:</p></div>
  363 +<div class="listingblock">
  364 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  365 +by Lorenzo Bettini
  366 +http://www.lorenzobettini.it
  367 +http://www.gnu.org/software/src-highlite -->
  368 +<pre><tt>Order<span style="color: #990000">.</span>scoped_by_customer_id<span style="color: #990000">(</span><span style="color: #993399">12</span><span style="color: #990000">)</span>
  369 +Order<span style="color: #990000">.</span>scoped_by_customer_id<span style="color: #990000">(</span><span style="color: #993399">12</span><span style="color: #990000">).</span>find<span style="color: #990000">(:</span>all<span style="color: #990000">,</span>
  370 + <span style="color: #990000">:</span>conditions <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"status = 'open'"</span><span style="color: #990000">)</span>
  371 +Order<span style="color: #990000">.</span>scoped_by_customer_id<span style="color: #990000">(</span><span style="color: #993399">12</span><span style="color: #990000">).</span>scoped_by_status<span style="color: #990000">(</span><span style="color: #FF0000">"open"</span><span style="color: #990000">)</span></tt></pre></div></div>
  372 +<div class="paragraph"><p>There&#8217;s nothing to define to use dynamic scopes: they just work.</p></div>
  373 +<div class="ulist"><ul>
  374 +<li>
  375 +<p>
  376 +Lead Contributor: <a href="http://evilmartians.com/">Yaroslav Markin</a>
  377 +</p>
  378 +</li>
  379 +<li>
  380 +<p>
  381 +More Information: <a href="http://ryandaigle.com/articles/2008/12/29/what-s-new-in-edge-rails-dynamic-scope-methods">What&#8217;s New in Edge Rails: Dynamic Scope Methods</a>.
  382 +</p>
  383 +</li>
  384 +</ul></div>
  385 +<h3 id="_default_scopes">3.4. Default Scopes</h3>
  386 +<div class="paragraph"><p>Rails 2.3 will introduce the notion of <em>default scopes</em> similar to named scopes, but applying to all named scopes or find methods within the model. For example, you can write <tt>default_scope :order =&gt; <em>name ASC</em></tt> and any time you retrieve records from that model they&#8217;ll come out sorted by name (unless you override the option, of course).</p></div>
  387 +<div class="ulist"><ul>
  388 +<li>
  389 +<p>
  390 +Lead Contributor: Paweł Kondzior
  391 +</p>
  392 +</li>
  393 +<li>
  394 +<p>
  395 +More Information: <a href="http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-default-scoping">What&#8217;s New in Edge Rails: Default Scoping</a>
  396 +</p>
  397 +</li>
  398 +</ul></div>
  399 +<h3 id="_multiple_conditions_for_callbacks">3.5. Multiple Conditions for Callbacks</h3>
  400 +<div class="paragraph"><p>When using Active Record callbacks, you can now combine <tt>:if</tt> and <tt>:unless</tt> options on the same callback, and supply multiple conditions as an array:</p></div>
  401 +<div class="listingblock">
  402 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  403 +by Lorenzo Bettini
  404 +http://www.lorenzobettini.it
  405 +http://www.gnu.org/software/src-highlite -->
  406 +<pre><tt>before_save <span style="color: #990000">:</span>update_credit_rating<span style="color: #990000">,</span> <span style="color: #990000">:</span><span style="font-weight: bold"><span style="color: #0000FF">if</span></span> <span style="color: #990000">=&gt;</span> <span style="color: #990000">:</span>active<span style="color: #990000">,</span>
  407 + <span style="color: #990000">:</span><span style="font-weight: bold"><span style="color: #0000FF">unless</span></span> <span style="color: #990000">=&gt;</span> <span style="color: #990000">[:</span>admin<span style="color: #990000">,</span> <span style="color: #990000">:</span>cash_only<span style="color: #990000">]</span></tt></pre></div></div>
  408 +<div class="ulist"><ul>
  409 +<li>
  410 +<p>
  411 +Lead Contributor: L. Caviola
  412 +</p>
  413 +</li>
  414 +</ul></div>
  415 +<h3 id="_find_with_having">3.6. Find with having</h3>
  416 +<div class="paragraph"><p>Rails now has a <tt>:having</tt> option on find (as well as on <tt>has_many</tt> and <tt>has_and_belongs_to_many</tt> associations) for filtering records in grouped finds. As those with heavy SQL backgrounds know, this allows filtering based on grouped results:</p></div>
  417 +<div class="listingblock">
  418 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  419 +by Lorenzo Bettini
  420 +http://www.lorenzobettini.it
  421 +http://www.gnu.org/software/src-highlite -->
  422 +<pre><tt>developers <span style="color: #990000">=</span> Developer<span style="color: #990000">.</span>find<span style="color: #990000">(:</span>all<span style="color: #990000">,</span> <span style="color: #990000">:</span>group <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"salary"</span><span style="color: #990000">,</span>
  423 + <span style="color: #990000">:</span>having <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"sum(salary) &gt; 10000"</span><span style="color: #990000">,</span> <span style="color: #990000">:</span>select <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"salary"</span><span style="color: #990000">)</span></tt></pre></div></div>
  424 +<div class="ulist"><ul>
  425 +<li>
  426 +<p>
  427 +Lead Contributor: <a href="http://github.com/miloops">Emilio Tagua</a>
  428 +</p>
  429 +</li>
  430 +</ul></div>
  431 +<h3 id="_hash_conditions_for_tt_has_many_tt_relationships">3.7. Hash Conditions for <tt>has_many</tt> relationships</h3>
  432 +<div class="paragraph"><p>You can once again use a hash in conditions for a <tt>has_many</tt> relationship:</p></div>
  433 +<div class="listingblock">
  434 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  435 +by Lorenzo Bettini
  436 +http://www.lorenzobettini.it
  437 +http://www.gnu.org/software/src-highlite -->
  438 +<pre><tt>has_many <span style="color: #990000">:</span>orders<span style="color: #990000">,</span> <span style="color: #990000">:</span>conditions <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">{</span><span style="color: #990000">:</span>status <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'confirmed'</span><span style="color: #FF0000">}</span></tt></pre></div></div>
  439 +<div class="paragraph"><p>That worked in Rails 2.1, fails in Rails 2.2, and will now work again in Rails 2.3 (if you&#8217;re dealing with this issue in Rails 2.2, you can use a string rather than a hash to specify conditions).</p></div>
  440 +<div class="ulist"><ul>
  441 +<li>
  442 +<p>
  443 +Lead Contributor: <a href="http://www.spacevatican.org/">Frederick Cheung</a>
  444 +</p>
  445 +</li>
  446 +</ul></div>
  447 +<h3 id="_reconnecting_mysql_connections">3.8. Reconnecting MySQL Connections</h3>
  448 +<div class="paragraph"><p>MySQL supports a reconnect flag in its connections - if set to true, then the client will try reconnecting to the server before giving up in case of a lost connection. You can now set <tt>reconnect = true</tt> for your MySQL connections in <tt>database.yml</tt> to get this behavior from a Rails application. The default is <tt>false</tt>, so the behavior of existing applications doesn&#8217;t change.</p></div>
  449 +<div class="ulist"><ul>
  450 +<li>
  451 +<p>
  452 +Lead Contributor: <a href="http://twitter.com/dubek">Dov Murik</a>
  453 +</p>
  454 +</li>
  455 +<li>
  456 +<p>
  457 +More information:
  458 +</p>
  459 +<div class="ulist"><ul>
  460 +<li>
  461 +<p>
  462 +<a href="http://dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html">Controlling Automatic Reconnection Behavior</a>
  463 +</p>
  464 +</li>
  465 +<li>
  466 +<p>
  467 +<a href="http://groups.google.com/group/rubyonrails-core/browse_thread/thread/49d2a7e9c96cb9f4">MySQL auto-reconnect revisited</a>
  468 +</p>
  469 +</li>
  470 +</ul></div>
  471 +</li>
  472 +</ul></div>
  473 +<h3 id="_other_active_record_changes">3.9. Other Active Record Changes</h3>
  474 +<div class="ulist"><ul>
  475 +<li>
  476 +<p>
  477 +An extra <tt>AS</tt> was removed from the generated SQL for has_and_belongs_to_many preloading, making it work better for some databases.
  478 +</p>
  479 +</li>
  480 +<li>
  481 +<p>
  482 +<tt>ActiveRecord::Base#new_record?</tt> now returns false rather than nil when confronted with an existing record.
  483 +</p>
  484 +</li>
  485 +<li>
  486 +<p>
  487 +A bug in quoting table names in some <tt>has_many :through</tt> associations was fixed.
  488 +</p>
  489 +</li>
  490 +<li>
  491 +<p>
  492 +You can now specify a particular timestamp for <tt>updated_at</tt> timestamps: <tt>cust = Customer.create(:name =&gt; "ABC Industries", :updated_at =&gt; 1.day.ago)</tt>
  493 +</p>
  494 +</li>
  495 +<li>
  496 +<p>
  497 +Better error messages on failed <tt>find_by_attribute!</tt> calls.
  498 +</p>
  499 +</li>
  500 +<li>
  501 +<p>
  502 +Active Record&#8217;s <tt>to_xml</tt> support gets just a little bit more flexible with the addition of a <tt>:camelize</tt> option.
  503 +</p>
  504 +</li>
  505 +<li>
  506 +<p>
  507 +A bug in canceling callbacks from <tt>before_update</tt> or +before_create_ was fixed.
  508 +</p>
  509 +</li>
  510 +<li>
  511 +<p>
  512 +Rake tasks for testing databases via JDBC have been added.
  513 +</p>
  514 +</li>
  515 +<li>
  516 +<p>
  517 +<tt>validates_length_of</tt> will use a custom error message with the <tt>:in</tt> or <tt>:within</tt> options (if one is supplied)
  518 +</p>
  519 +</li>
  520 +</ul></div>
  521 +</div>
  522 +<h2 id="_action_controller">4. Action Controller</h2>
  523 +<div class="sectionbody">
  524 +<div class="paragraph"><p>Action Controller rolls out some significant changes to rendering, as well as improvements in routing and other areas, in this release.</p></div>
  525 +<h3 id="_unified_rendering">4.1. Unified Rendering</h3>
  526 +<div class="paragraph"><p><tt>ActionController::Base#render</tt> is a lot smarter about deciding what to render. Now you can just tell it what to render and expect to get the right results. In older versions of Rails, you often need to supply explicit information to render:</p></div>
  527 +<div class="listingblock">
  528 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  529 +by Lorenzo Bettini
  530 +http://www.lorenzobettini.it
  531 +http://www.gnu.org/software/src-highlite -->
  532 +<pre><tt>render <span style="color: #990000">:</span>file <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'/tmp/random_file.erb'</span>
  533 +render <span style="color: #990000">:</span>template <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'other_controller/action'</span>
  534 +render <span style="color: #990000">:</span>action <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'show'</span></tt></pre></div></div>
  535 +<div class="paragraph"><p>Now in Rails 2.3, you can just supply what you want to render:</p></div>
  536 +<div class="listingblock">
  537 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  538 +by Lorenzo Bettini
  539 +http://www.lorenzobettini.it
  540 +http://www.gnu.org/software/src-highlite -->
  541 +<pre><tt>render <span style="color: #FF0000">'/tmp/random_file.erb'</span>
  542 +render <span style="color: #FF0000">'other_controller/action'</span>
  543 +render <span style="color: #FF0000">'show'</span>
  544 +render <span style="color: #990000">:</span>show</tt></pre></div></div>
  545 +<div class="paragraph"><p>Rails chooses between file, template, and action depending on whether there is a leading slash, an embedded slash, or no slash at all in what&#8217;s to be rendered. Note that you can also use a symbol instead of a string when rendering an action. Other rendering styles (<tt>:inline</tt>, <tt>:text</tt>, <tt>:update</tt>, <tt>:nothing</tt>, <tt>:json</tt>, <tt>:xml</tt>, <tt>:js</tt>) still require an explicit option.</p></div>
  546 +<h3 id="_application_controller_renamed">4.2. Application Controller Renamed</h3>
  547 +<div class="paragraph"><p>If you&#8217;re one of the people who has always been bothered by the special-case naming of <tt>application.rb</tt>, rejoice! It&#8217;s been reworked to be application_controller.rb in Rails 2.3. In addition, there&#8217;s a new rake task, <tt>rake rails:update:application_controller</tt> to do this automatically for you - and it will be run as part of the normal <tt>rake rails:update</tt> process.</p></div>
  548 +<div class="ulist"><ul>
  549 +<li>
  550 +<p>
  551 +More Information:
  552 +</p>
  553 +<div class="ulist"><ul>
  554 +<li>
  555 +<p>
  556 +<a href="http://afreshcup.com/2008/11/17/rails-2x-the-death-of-applicationrb/">The Death of Application.rb</a>
  557 +</p>
  558 +</li>
  559 +<li>
  560 +<p>
  561 +<a href="http://ryandaigle.com/articles/2008/11/19/what-s-new-in-edge-rails-application-rb-duality-is-no-more">What&#8217;s New in Edge Rails: Application.rb Duality is no More</a>
  562 +</p>
  563 +</li>
  564 +</ul></div>
  565 +</li>
  566 +</ul></div>
  567 +<h3 id="_http_digest_authentication_support">4.3. HTTP Digest Authentication Support</h3>
  568 +<div class="paragraph"><p>Rails now has built-in support for HTTP digest authentication. To use it, you call <tt>authenticate_or_request_with_http_digest</tt> with a block that returns the user’s password (which is then hashed and compared against the transmitted credentials):</p></div>
  569 +<div class="listingblock">
  570 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  571 +by Lorenzo Bettini
  572 +http://www.lorenzobettini.it
  573 +http://www.gnu.org/software/src-highlite -->
  574 +<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> PostsController <span style="color: #990000">&lt;</span> ApplicationController
  575 + Users <span style="color: #990000">=</span> <span style="color: #FF0000">{</span><span style="color: #FF0000">"dhh"</span> <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"secret"</span><span style="color: #FF0000">}</span>
  576 + before_filter <span style="color: #990000">:</span>authenticate
  577 +
  578 + <span style="font-weight: bold"><span style="color: #0000FF">def</span></span> secret
  579 + render <span style="color: #990000">:</span>text <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"Password Required!"</span>
  580 + <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
  581 +
  582 + private
  583 + <span style="font-weight: bold"><span style="color: #0000FF">def</span></span> authenticate
  584 + realm <span style="color: #990000">=</span> <span style="color: #FF0000">"Application"</span>
  585 + authenticate_or_request_with_http_digest<span style="color: #990000">(</span>realm<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>name<span style="color: #990000">|</span>
  586 + Users<span style="color: #990000">[</span>name<span style="color: #990000">]</span>
  587 + <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
  588 + <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
  589 +<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
  590 +<div class="ulist"><ul>
  591 +<li>
  592 +<p>
  593 +Lead Contributor: <a href="http://www.kellogg-assoc.com/">Gregg Kellogg</a>
  594 +</p>
  595 +</li>
  596 +<li>
  597 +<p>
  598 +More Information: <a href="http://ryandaigle.com/articles/2009/1/30/what-s-new-in-edge-rails-http-digest-authentication">What&#8217;s New in Edge Rails: HTTP Digest Authentication</a>
  599 +</p>
  600 +</li>
  601 +</ul></div>
  602 +<h3 id="_more_efficient_routing">4.4. More Efficient Routing</h3>
  603 +<div class="paragraph"><p>There are a couple of significant routing changes in Rails 2.3. The <tt>formatted_</tt> route helpers are gone, in favor just passing in <tt>:format</tt> as an option. This cuts down the route generation process by 50% for any resource - and can save a substantial amount of memory (up to 100MB on large applications). If your code uses the <tt>formatted_</tt> helpers, it will still work for the time being - but that behavior is deprecated and your application will be more efficient if you rewrite those routes using the new standard. Another big change is that Rails now supports multiple routing files, not just routes.rb. You can use <tt>RouteSet#add_configuration_file</tt> to bring in more routes at any time - without clearing the currently-loaded routes. While this change is most useful for Engines, you can use it in any application that needs to load routes in batches.</p></div>
  604 +<div class="paragraph"><p>Lead Contributors: <a href="http://blog.hungrymachine.com/">Aaron Batalion</a></p></div>
  605 +<h3 id="_rack_based_lazy_loaded_sessions">4.5. Rack-based Lazy-loaded Sessions</h3>
  606 +<div class="paragraph"><p>A big change pushed the underpinnings of Action Controller session storage down to the Rack level. This involved a good deal of work in the code, though it should be completely transparent to your Rails applications (as a bonus, some icky patches around the old CGI session handler got removed). It&#8217;s still significant, though, for one simple reason: non-Rails Rack applications have access to the same session storage handlers (and therefore the same session) as your Rails applications. In addition, sessions are now lazy-loaded (in line with the loading improvements to the rest of the framework). This means that you no longer need to explicitly disable sessions if you don&#8217;t want them; just don&#8217;t refer to them and they won&#8217;t load.</p></div>
  607 +<h3 id="_mime_type_handling_changes">4.6. MIME Type Handling Changes</h3>
  608 +<div class="paragraph"><p>There are a couple of changes to the code for handling MIME types in Rails. First, <tt>MIME::Type</tt> now implements the <tt>=~</tt> operator, making things much cleaner when you need to check for the presence of a type that has synonyms:</p></div>
  609 +<div class="listingblock">
  610 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  611 +by Lorenzo Bettini
  612 +http://www.lorenzobettini.it
  613 +http://www.gnu.org/software/src-highlite -->
  614 +<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">if</span></span> content_type <span style="color: #990000">&amp;&amp;</span> Mime<span style="color: #990000">::</span>JS <span style="color: #990000">=~</span> content_type
  615 + <span style="font-style: italic"><span style="color: #9A1900"># do something cool</span></span>
  616 +<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
  617 +
  618 +Mime<span style="color: #990000">::</span>JS <span style="color: #990000">=~</span> <span style="color: #FF0000">"text/javascript"</span> <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span>
  619 +Mime<span style="color: #990000">::</span>JS <span style="color: #990000">=~</span> <span style="color: #FF0000">"application/javascript"</span> <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span></tt></pre></div></div>
  620 +<div class="paragraph"><p>The other change is that the framework now uses the <tt>Mime::JS</tt> when checking for javascript in various spots, making it handle those alternatives cleanly.</p></div>
  621 +<div class="paragraph"><p>Lead Contributor: <a href="http://www.workingwithrails.com/person/5510-seth-fitzsimmons">Seth Fitzsimmons</a></p></div>
  622 +<h3 id="_optimization_of_tt_respond_to_tt">4.7. Optimization of <tt>respond_to</tt></h3>
  623 +<div class="paragraph"><p>In some of the first fruits of the Rails-Merb team merger, Rails 2.3 includes some optimizations for the <tt>respond_to</tt> method, which is of course heavily used in many Rails applications to allow your controller to format results differently based on the MIME type of the incoming request. After eliminating a call to <tt>method_missing</tt> and some profiling and tweaking, we&#8217;re seeing an 8% improvement in the number of requests per second served with a simple <tt>respond_to</tt> that switches between three formats. The best part? No change at all required to the code of your application to take advantage of this speedup.</p></div>
  624 +<h3 id="_improved_caching_performance">4.8. Improved Caching Performance</h3>
  625 +<div class="paragraph"><p>Rails now keeps a per-request local cache of requests, cutting down on unnecessary reads and leading to better site performance. While this work was originally limited to <tt>MemCacheStore</tt>, it is available to any remote store than implements the required methods.</p></div>
  626 +<div class="ulist"><ul>
  627 +<li>
  628 +<p>
  629 +Lead Contributor: <a href="http://www.motionstandingstill.com/">Nahum Wild</a>
  630 +</p>
  631 +</li>
  632 +</ul></div>
  633 +<h3 id="_localized_views">4.9. Localized Views</h3>
  634 +<div class="paragraph"><p>Rails can now provide localized views, depending on the locale that you have set. For example, suppose you have a <tt>Posts</tt> controller with a <tt>show</tt> action. By default, this will render <tt>app/views/posts/show.html.erb</tt>. But if you set <tt>I18n.locale = :da</tt>, it will render <tt>app/views/posts/show.da.html.erb</tt>. If the localized template isn&#8217;t present, the undecorated version will be used. Rails also includes <tt>I18n#available_locales</tt> and <tt>I18n::SimpleBackend#available_locales</tt>, which return an array of the translations that are available in the current Rails project.</p></div>
  635 +<h3 id="_other_action_controller_changes">4.10. Other Action Controller Changes</h3>
  636 +<div class="ulist"><ul>
  637 +<li>
  638 +<p>
  639 +ETag handling has been cleaned up a bit: Rails will now skip sending an ETag header when there&#8217;s no body to the response or when sending files with <tt>send_file</tt>.
  640 +</p>
  641 +</li>
  642 +<li>
  643 +<p>
  644 +The fact that Rails checks for IP spoofing can be a nuisance for sites that do heavy traffic with cell phones, because their proxies don&#8217;t generally set things up right. If that&#8217;s you, you can now set <tt>ActionController::Base.ip_spoofing_check = false</tt> to disable the check entirely.
  645 +</p>
  646 +</li>
  647 +<li>
  648 +<p>
  649 +<tt>ActionController::Dispatcher</tt> now implements its own middleware stack, which you can see by running <tt>rake middleware</tt>.
  650 +</p>
  651 +</li>
  652 +<li>
  653 +<p>
  654 +Cookie sessions now have persistent session identifiers, with API compatibility with the server-side stores.
  655 +</p>
  656 +</li>
  657 +<li>
  658 +<p>
  659 +You can now use symbols for the <tt>:type</tt> option of <tt>send_file</tt> and <tt>send_data</tt>, like this: <tt>send_file("fabulous.png", :type =&gt; :png)</tt>.
  660 +</p>
  661 +</li>
  662 +<li>
  663 +<p>
  664 +The <tt>:only</tt> and <tt>:except</tt> options for <tt>map.resources</tt> are no longer inherited by nested resources.
  665 +</p>
  666 +</li>
  667 +</ul></div>
  668 +</div>
  669 +<h2 id="_action_view">5. Action View</h2>
  670 +<div class="sectionbody">
  671 +<div class="paragraph"><p>Action View in Rails 2.3 picks up nested model forms, improvements to <tt>render</tt>, more flexible prompts for the date select helpers, and a speedup in asset caching, among other things.</p></div>
  672 +<h3 id="_nested_object_forms">5.1. Nested Object Forms</h3>
  673 +<div class="paragraph"><p>Provided the parent model accepts nested attributes for the child objects (as discussed in the Active Record section), you can create nested forms using <tt>form_for</tt> and <tt>field_for</tt>. These forms can be nested arbitrarily deep, allowing you to edit complex object hierarchies on a single view without excessive code. For example, given this model:</p></div>
  674 +<div class="listingblock">
  675 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  676 +by Lorenzo Bettini
  677 +http://www.lorenzobettini.it
  678 +http://www.gnu.org/software/src-highlite -->
  679 +<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> Customer <span style="color: #990000">&lt;</span> ActiveRecord<span style="color: #990000">::</span>Base
  680 + has_many <span style="color: #990000">:</span>orders
  681 +
  682 + accepts_nested_attributes_for <span style="color: #990000">:</span>orders<span style="color: #990000">,</span> <span style="color: #990000">:</span>allow_destroy <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span>
  683 +<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
  684 +<div class="paragraph"><p>You can write this view in Rails 2.3:</p></div>
  685 +<div class="listingblock">
  686 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  687 +by Lorenzo Bettini
  688 +http://www.lorenzobettini.it
  689 +http://www.gnu.org/software/src-highlite -->
  690 +<pre><tt><span style="color: #FF0000">&lt;% form_for @customer do |customer_form| %&gt;</span>
  691 + <span style="color: #FF0000">&lt;div&gt;</span>
  692 + <span style="color: #FF0000">&lt;%= customer_form.label :name, 'Customer Name:' %&gt;</span>
  693 + <span style="color: #FF0000">&lt;%= customer_form.text_field :name %&gt;</span>
  694 + <span style="color: #FF0000">&lt;/div&gt;</span>
  695 +
  696 + <span style="color: #990000">&lt;!--</span> Here we call fields_for on the customer_form builder instance<span style="color: #990000">.</span>
  697 + The block is called <span style="font-weight: bold"><span style="color: #0000FF">for</span></span> each member of the orders collection<span style="color: #990000">.</span> <span style="color: #990000">--&gt;</span>
  698 + <span style="color: #FF0000">&lt;% customer_form.fields_for :orders do |order_form| %&gt;</span>
  699 + <span style="color: #FF0000">&lt;p&gt;</span>
  700 + <span style="color: #FF0000">&lt;div&gt;</span>
  701 + <span style="color: #FF0000">&lt;%= order_form.label :number, 'Order Number:' %&gt;</span>
  702 + <span style="color: #FF0000">&lt;%= order_form.text_field :number %&gt;</span>
  703 + <span style="color: #FF0000">&lt;/div&gt;</span>
  704 +
  705 + <span style="color: #990000">&lt;!--</span> The allow_destroy option <span style="font-weight: bold"><span style="color: #0000FF">in</span></span> the model enables deletion of
  706 + child records<span style="color: #990000">.</span> <span style="color: #990000">--&gt;</span>
  707 + <span style="color: #FF0000">&lt;% unless order_form.object.new_record? %&gt;</span>
  708 + <span style="color: #FF0000">&lt;div&gt;</span>
  709 + <span style="color: #FF0000">&lt;%= order_form.label :_delete, 'Remove:' %&gt;</span>
  710 + <span style="color: #FF0000">&lt;%= order_form.check_box :_delete %&gt;</span>
  711 + <span style="color: #FF0000">&lt;/div&gt;</span>
  712 + <span style="color: #FF0000">&lt;% end %&gt;</span>
  713 + <span style="color: #FF0000">&lt;/p&gt;</span>
  714 + <span style="color: #FF0000">&lt;% end %&gt;</span>
  715 + <span style="color: #FF0000">&lt;% end %&gt;</span>
  716 +
  717 + <span style="color: #FF0000">&lt;%= customer_form.submit %&gt;</span>
  718 +<span style="color: #FF0000">&lt;% end %&gt;</span></tt></pre></div></div>
  719 +<div class="ulist"><ul>
  720 +<li>
  721 +<p>
  722 +Lead Contributor: link_to:<a href="http://www.superalloy.nl/blog/">Eloy Duran</a>
  723 +</p>
  724 +</li>
  725 +<li>
  726 +<p>
  727 +More Information:
  728 +</p>
  729 +<div class="ulist"><ul>
  730 +<li>
  731 +<p>
  732 +link_to:<a href="http://weblog.rubyonrails.org/2009/1/26/nested-model-forms">Nested Model Forms</a>
  733 +</p>
  734 +</li>
  735 +<li>
  736 +<p>
  737 +link_to:<a href="http://github.com/alloy/complex-form-examples/tree/nested_attributes">complex-form-examples</a>
  738 +</p>
  739 +</li>
  740 +<li>
  741 +<p>
  742 +link_to:<a href="http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes">What&#8217;s New in Edge Rails: Nested Object Forms</a>
  743 +</p>
  744 +</li>
  745 +</ul></div>
  746 +</li>
  747 +</ul></div>
  748 +<h3 id="_smart_rendering_of_partials">5.2. Smart Rendering of Partials</h3>
  749 +<div class="paragraph"><p>The render method has been getting smarter over the years, and it&#8217;s even smarter now. If you have an object or a collection and an appropriate partial, and the naming matches up, you can now just render the object and things will work. For example, in Rails 2.3, these render calls will work in your view (assuming sensible naming):</p></div>
  750 +<div class="listingblock">
  751 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  752 +by Lorenzo Bettini
  753 +http://www.lorenzobettini.it
  754 +http://www.gnu.org/software/src-highlite -->
  755 +<pre><tt>render <span style="color: #009900">@article</span> <span style="font-style: italic"><span style="color: #9A1900"># Equivalent of render :partial =&gt; 'articles/_article', :object =&gt; @article</span></span>
  756 +render <span style="color: #009900">@articles</span> <span style="font-style: italic"><span style="color: #9A1900"># Equivalent of render :partial =&gt; 'articles/_article', :collection =&gt; @articles</span></span></tt></pre></div></div>
  757 +<div class="ulist"><ul>
  758 +<li>
  759 +<p>
  760 +More Information: <a href="http://ryandaigle.com/articles/2008/11/20/what-s-new-in-edge-rails-render-stops-being-high-maintenance">What&#8217;s New in Edge Rails: render Stops Being High-Maintenance</a>
  761 +</p>
  762 +</li>
  763 +</ul></div>
  764 +<h3 id="_prompts_for_date_select_helpers">5.3. Prompts for Date Select Helpers</h3>
  765 +<div class="paragraph"><p>In Rails 2.3, you can supply custom prompts for the various date select helpers (<tt>date_select</tt>, <tt>time_select</tt>, and <tt>datetime_select</tt>), the same way you can with collection select helpers. You can supply a prompt string or a hash of individual prompt strings for the various components. You can also just set <tt>:prompt</tt> to <tt>true</tt> to use the custom generic prompt:</p></div>
  766 +<div class="listingblock">
  767 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  768 +by Lorenzo Bettini
  769 +http://www.lorenzobettini.it
  770 +http://www.gnu.org/software/src-highlite -->
  771 +<pre><tt>select_datetime<span style="color: #990000">(</span>DateTime<span style="color: #990000">.</span>now<span style="color: #990000">,</span> <span style="color: #990000">:</span>prompt <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">)</span>
  772 +
  773 +select_datetime<span style="color: #990000">(</span>DateTime<span style="color: #990000">.</span>now<span style="color: #990000">,</span> <span style="color: #990000">:</span>prompt <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"Choose date and time"</span><span style="color: #990000">)</span>
  774 +
  775 +select_datetime<span style="color: #990000">(</span>DateTime<span style="color: #990000">.</span>now<span style="color: #990000">,</span> <span style="color: #990000">:</span>prompt <span style="color: #990000">=&gt;</span>
  776 + <span style="color: #FF0000">{</span><span style="color: #990000">:</span>day <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'Choose day'</span><span style="color: #990000">,</span> <span style="color: #990000">:</span>month <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'Choose month'</span><span style="color: #990000">,</span>
  777 + <span style="color: #990000">:</span>year <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'Choose year'</span><span style="color: #990000">,</span> <span style="color: #990000">:</span>hour <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'Choose hour'</span><span style="color: #990000">,</span>
  778 + <span style="color: #990000">:</span>minute <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">'Choose minute'</span><span style="color: #FF0000">}</span><span style="color: #990000">)</span></tt></pre></div></div>
  779 +<div class="paragraph"><p>Lead Contributor: <a href="http://samoliver.com/">Sam Oliver</a></p></div>
  780 +<h3 id="_assettag_timestamp_caching">5.4. AssetTag Timestamp Caching</h3>
  781 +<div class="paragraph"><p>You&#8217;re likely familiar with Rails' practice of adding timestamps to static asset paths as a "cache buster." This helps ensure that stale copies of things like images and stylesheets don&#8217;t get served out of the user&#8217;s browser cache when you change them on the server. You can now modify this behavior with the <tt>cache_asset_timestamps</tt> configuration option for Action View. If you enable the cache, then Rails will calculate the timestamp once when it first serves an asset, and save that value. This means fewer (expensive) file system calls to serve static assets - but it also means that you can&#8217;t modify any of the assets while the server is running and expect the changes to get picked up by clients.</p></div>
  782 +<h3 id="_asset_hosts_as_objects">5.5. Asset Hosts as Objects</h3>
  783 +<div class="paragraph"><p>Asset hosts get more flexible in edge Rails with the ability to declare an asset host as a specific object that responds to a call. This allows you to to implement any complex logic you need in your asset hosting.</p></div>
  784 +<div class="ulist"><ul>
  785 +<li>
  786 +<p>
  787 +More Information: <a href="http://github.com/dhh/asset-hosting-with-minimum-ssl/tree/master">asset-hosting-with-minimum-ssl</a>
  788 +</p>
  789 +</li>
  790 +</ul></div>
  791 +<h3 id="_grouped_options_for_select_helper_method">5.6. grouped_options_for_select Helper Method</h3>
  792 +<div class="paragraph"><p>Action View already haD a bunch of helpers to aid in generating select controls, but now there&#8217;s one more: <tt>grouped_options_for_select</tt>. This one accepts an array or hash of strings, and converts them into a string of <tt>option</tt> tags wrapped with <tt>optgroup</tt> tags. For example:</p></div>
  793 +<div class="listingblock">
  794 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  795 +by Lorenzo Bettini
  796 +http://www.lorenzobettini.it
  797 +http://www.gnu.org/software/src-highlite -->
  798 +<pre><tt>grouped_options_for_select<span style="color: #990000">([[</span><span style="color: #FF0000">"Hats"</span><span style="color: #990000">,</span> <span style="color: #990000">[</span><span style="color: #FF0000">"Baseball Cap"</span><span style="color: #990000">,</span><span style="color: #FF0000">"Cowboy Hat"</span><span style="color: #990000">]]],</span>
  799 + <span style="color: #FF0000">"Cowboy Hat"</span><span style="color: #990000">,</span> <span style="color: #FF0000">"Choose a product..."</span><span style="color: #990000">)</span></tt></pre></div></div>
  800 +<div class="paragraph"><p>returns</p></div>
  801 +<div class="listingblock">
  802 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  803 +by Lorenzo Bettini
  804 +http://www.lorenzobettini.it
  805 +http://www.gnu.org/software/src-highlite -->
  806 +<pre><tt><span style="color: #FF0000">&lt;option value=""&gt;</span>Choose a product<span style="color: #990000">...</span><span style="color: #FF0000">&lt;/option&gt;</span>
  807 +<span style="color: #FF0000">&lt;optgroup label="Hats"&gt;</span>
  808 + <span style="color: #FF0000">&lt;option value="Baseball Cap"&gt;</span>Baseball Cap<span style="color: #FF0000">&lt;/option&gt;</span>
  809 + <span style="color: #FF0000">&lt;option selected="selected" value="Cowboy Hat"&gt;</span>Cowboy Hat<span style="color: #FF0000">&lt;/option&gt;</span>
  810 +<span style="color: #FF0000">&lt;/optgroup&gt;</span></tt></pre></div></div>
  811 +<h3 id="_other_action_view_changes">5.7. Other Action View Changes</h3>
  812 +<div class="ulist"><ul>
  813 +<li>
  814 +<p>
  815 +Token generation for CSRF protection has been simplified; now Rails uses a simple random string generated by <tt>ActiveSupport::SecureRandom</tt> rather than mucking around with session IDs.
  816 +</p>
  817 +</li>
  818 +<li>
  819 +<p>
  820 +<tt>auto_link</tt> now properly applies options (such as :target and :class) to generated e-mail links.
  821 +</p>
  822 +</li>
  823 +<li>
  824 +<p>
  825 +The <tt>autolink</tt> helper has been refactored to make it a bit less messy and more intuitive.
  826 +</p>
  827 +</li>
  828 +</ul></div>
  829 +</div>
  830 +<h2 id="_active_support">6. Active Support</h2>
  831 +<div class="sectionbody">
  832 +<div class="paragraph"><p>Active Support has a few interesting changes, including the introduction of <tt>Object#try</tt>.</p></div>
  833 +<h3 id="_object_try">6.1. Object#try</h3>
  834 +<div class="paragraph"><p>A lot of folks have adopted the notion of using try() to attempt operations on objects - It&#8217;s especially helpful in views where you can avoid nil-checking by writing code like <tt>&lt;%= @person.try(:name) %&gt;</tt>. Well, now it&#8217;s baked right into Rails. As implemented in Rails, it raises <tt>NoMethodError</tt> on private methods and always returns <tt>nil</tt> if the object is nil.</p></div>
  835 +<div class="ulist"><ul>
  836 +<li>
  837 +<p>
  838 +More Information: <a href="http://ozmm.org/posts/try.html">try()</a>.
  839 +</p>
  840 +</li>
  841 +</ul></div>
  842 +<h3 id="_object_tap_backport">6.2. Object#tap Backport</h3>
  843 +<div class="paragraph"><p><tt>Object#tap</tt> is an addition to "Ruby 1.9":http://www.ruby-doc.org/core-1.9/classes/Object.html#M000309 and 1.8.7 that is similar to the <tt>returning</tt> method that Rails has had for a while: it yields to a block, and then returns the object that was yielded. Rails now includes code to make this available under older versions of Ruby as well.</p></div>
  844 +<h3 id="_fractional_seconds_for_timewithzone">6.3. Fractional seconds for TimeWithZone</h3>
  845 +<div class="paragraph"><p>The <tt>Time</tt> and <tt>TimeWithZone</tt> classes include an <tt>xmlschema</tt> method to return the time in an XML-friendly string. As of Rails 2.3, <tt>TimeWithZone</tt> supports the same argument for specifying the number of digits in the fractional second part of the returned string that <tt>Time</tt> does:</p></div>
  846 +<div class="listingblock">
  847 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  848 +by Lorenzo Bettini
  849 +http://www.lorenzobettini.it
  850 +http://www.gnu.org/software/src-highlite -->
  851 +<pre><tt><span style="color: #990000">&gt;&gt;</span> Time<span style="color: #990000">.</span>zone<span style="color: #990000">.</span>now<span style="color: #990000">.</span>xmlschema<span style="color: #990000">(</span><span style="color: #993399">6</span><span style="color: #990000">)</span>
  852 +<span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"2009-01-16T13:00:06.13653Z"</span></tt></pre></div></div>
  853 +<div class="paragraph"><p>Lead Contributor: <a href="http://www.workingwithrails.com/person/13536-nicholas-dainty">Nicholas Dainty</a></p></div>
  854 +<h3 id="_json_key_quoting">6.4. JSON Key Quoting</h3>
  855 +<div class="paragraph"><p>If you look up the spec on the "json.org" site, you&#8217;ll discover that all keys in a JSON structure must be strings, and they must be quoted with double quotes. Starting with Rails 2.3, we doe the right thing here, even with numeric keys.</p></div>
  856 +<h3 id="_other_active_support_changes">6.5. Other Active Support Changes</h3>
  857 +<div class="ulist"><ul>
  858 +<li>
  859 +<p>
  860 +You can use <tt>Enumerable#none?</tt> to check that none of the elements match the supplied block.
  861 +</p>
  862 +</li>
  863 +<li>
  864 +<p>
  865 +If you&#8217;re using Active Support <a href="http://afreshcup.com/2008/10/19/coming-in-rails-22-delegate-prefixes/">delegates</a>, the new <tt>:allow_nil</tt> option lets you return nil instead of raising an exception when the target object is nil.
  866 +</p>
  867 +</li>
  868 +<li>
  869 +<p>
  870 +<tt>ActiveSupport::OrderedHash</tt>: now implements <tt>each_key</tt> and <tt>each_value</tt>.
  871 +</p>
  872 +</li>
  873 +<li>
  874 +<p>
  875 +<tt>ActiveSupport::MessageEncryptor</tt> provides a simple way to encrypt information for storage in an untrusted location (like cookies).
  876 +</p>
  877 +</li>
  878 +<li>
  879 +<p>
  880 +Active Support&#8217;s <tt>from_xml</tt> no longer depends on XmlSimple. Instead, Rails now includes its own XmlMini implementation, with just the functionality that it requires. This lets Rails dispense with the bundled copy of XmlSimple that it&#8217;s been carting around.
  881 +</p>
  882 +</li>
  883 +</ul></div>
  884 +</div>
  885 +<h2 id="_railties">7. Railties</h2>
  886 +<div class="sectionbody">
  887 +<div class="paragraph"><p>In addition to the Rack changes covered above, Railties (the core code of Rails itself) sports a number of significant changes, including Rails Metal, application templates, and quiet backtraces.</p></div>
  888 +<h3 id="_rails_metal">7.1. Rails Metal</h3>
  889 +<div class="paragraph"><p>Rails Metal is a new mechanism that provides superfast endpoints inside of your Rails applications. Metal classes bypass routing and Action Controller to give you raw speed (at the cost of all the things in Action Controller, of course). This builds on all of the recent foundation work to make Rails a Rack application with an exposed middleware stack.</p></div>
  890 +<div class="ulist"><ul>
  891 +<li>
  892 +<p>
  893 +More Information:
  894 +</p>
  895 +<div class="ulist"><ul>
  896 +<li>
  897 +<p>
  898 +<a href="http://weblog.rubyonrails.org/2008/12/17/introducing-rails-metal">Introducing Rails Metal</a>
  899 +</p>
  900 +</li>
  901 +<li>
  902 +<p>
  903 +<a href="http://soylentfoo.jnewland.com/articles/2008/12/16/rails-metal-a-micro-framework-with-the-power-of-rails-m">Rails Metal: a micro-framework with the power of Rails</a>
  904 +</p>
  905 +</li>
  906 +<li>
  907 +<p>
  908 +<a href="http://www.railsinside.com/deployment/180-metal-super-fast-endpoints-within-your-rails-apps.html">Metal: Super-fast Endpoints within your Rails Apps</a>
  909 +</p>
  910 +</li>
  911 +<li>
  912 +<p>
  913 +<a href="http://ryandaigle.com/articles/2008/12/18/what-s-new-in-edge-rails-rails-metal">What&#8217;s New in Edge Rails: Rails Metal</a>
  914 +</p>
  915 +</li>
  916 +</ul></div>
  917 +</li>
  918 +</ul></div>
  919 +<h3 id="_application_templates">7.2. Application Templates</h3>
  920 +<div class="paragraph"><p>Rails 2.3 incorporates Jeremy McAnally&#8217;s <a href="http://github.com/jeremymcanally/rg/tree/master">rg</a> application generator. What this means is that we now have template-based application generation built right into Rails; if you have a set of plugins you include in every application (among many other use cases), you can just set up a template once and use it over and over again when you run the <tt>rails</tt> command. There&#8217;s also a rake task to apply a template to an existing application:</p></div>
  921 +<div class="listingblock">
  922 +<div class="content"><!-- Generator: GNU source-highlight 2.9
  923 +by Lorenzo Bettini
  924 +http://www.lorenzobettini.it
  925 +http://www.gnu.org/software/src-highlite -->
  926 +<pre><tt>rake rails<span style="color: #990000">:</span>template LOCATION<span style="color: #990000">=~/</span>template<span style="color: #990000">.</span>rb</tt></pre></div></div>
  927 +<div class="paragraph"><p>This will layer the changes from the template on top of whatever code the project already contains.</p></div>
  928 +<div class="ulist"><ul>
  929 +<li>
  930 +<p>
  931 +Lead Contributor: <a href="http://www.jeremymcanally.com/">Jeremy McAnally</a>
  932 +</p>
  933 +</li>
  934 +<li>
  935 +<p>
  936 +More Info:<a href="http://m.onkey.org/2008/12/4/rails-templates">Rails templates</a>
  937 +</p>
  938 +</li>
  939 +</ul></div>
  940 +<h3 id="_quieter_backtraces">7.3. Quieter Backtraces</h3>
  941 +<div class="paragraph"><p>Building on Thoughtbot&#8217;s <a href="http://www.thoughtbot.com/projects/quietbacktrace">Quiet Backtrace</a> plugin, which allows you to selectively remove lines from <tt>Test::Unit</tt> backtraces, Rails 2.3 implements <tt>ActiveSupport::BacktraceCleaner</tt> and <tt>Rails::BacktraceCleaner</tt> in core. This supports both filters (to perform regex-based substitutions on backtrace lines) and silencers (to remove backtrace lines entirely). Rails automatically adds silencers to get rid of the most common noise in a new application, and builds a <tt>config/backtrace_silencers.rb</tt> file to hold your own additions. This feature also enables prettier printing from any gem in the backtrace.</p></div>
  942 +<h3 id="_faster_boot_time_in_development_mode_with_lazy_loading_autoload">7.4. Faster Boot Time in Development Mode with Lazy Loading/Autoload</h3>
  943 +<div class="paragraph"><p>Quite a bit of work was done to make sure that bits of Rails (and its dependencies) are only brought into memory when they&#8217;re actually needed. The core frameworks - Active Support, Active Record, Action Controller, Action Mailer and Action View - are now using <tt>autoload</tt> to lazy-load their individual classes. This work should help keep the memory footprint down and improve overall Rails performance.</p></div>
  944 +<div class="paragraph"><p>You can also specify (by using the new <tt>preload_frameworks</tt> option) whether the core libraries should be autoloaded at startup. This defaults to <tt>false</tt> so that Rails autoloads itself piece-by-piece, but there are some circumstances where you still need to bring in everything at once - Passenger and JRuby both want to see all of Rails loaded together.</p></div>
  945 +<h3 id="_other_railties_changes">7.5. Other Railties Changes</h3>
  946 +<div class="ulist"><ul>
  947 +<li>
  948 +<p>
  949 +The instructions for updating a CI server to build Rails have been updated and expanded.
  950 +</p>
  951 +</li>
  952 +<li>
  953 +<p>
  954 +Internal Rails testing has been switched from <tt>Test::Unit::TestCase</tt> to <tt>ActiveSupport::TestCase</tt>, and the Rails core requires Mocha to test.
  955 +</p>
  956 +</li>
  957 +<li>
  958 +<p>
  959 +The default <tt>environment.rb</tt> file has been decluttered.
  960 +</p>
  961 +</li>
  962 +<li>
  963 +<p>
  964 +The dbconsole script now lets you use an all-numeric password without crashing.