aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides
diff options
context:
space:
mode:
authorAditya Chadha <aditya@sublucid.com>2009-02-23 17:21:36 -0500
committerAditya Chadha <aditya@sublucid.com>2009-02-23 17:21:36 -0500
commit3e7015b7967b355c0fb6868db11aeddf9b43ad74 (patch)
treef002805b7e5e9325019ca910917c3743fd18f95c /railties/guides
parentbb1ce5d199df115ddcc82b1b8dfafe14064fe031 (diff)
parent5cf7cbf6a6c40d5eea75fe919a7e6460bf64508b (diff)
downloadrails-3e7015b7967b355c0fb6868db11aeddf9b43ad74.tar.gz
rails-3e7015b7967b355c0fb6868db11aeddf9b43ad74.tar.bz2
rails-3e7015b7967b355c0fb6868db11aeddf9b43ad74.zip
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'railties/guides')
-rw-r--r--railties/guides/source/2_3_release_notes.textile26
-rw-r--r--railties/guides/source/layout.html.erb2
2 files changed, 25 insertions, 3 deletions
diff --git a/railties/guides/source/2_3_release_notes.textile b/railties/guides/source/2_3_release_notes.textile
index 9642dbdad0..4734e32606 100644
--- a/railties/guides/source/2_3_release_notes.textile
+++ b/railties/guides/source/2_3_release_notes.textile
@@ -42,7 +42,7 @@ Here's a summary of the rack-related changes:
h4. Renewed Support for Rails Engines
-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 +routes.rb+ 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.
+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 +routes.rb+ 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, and Action Mailer as well as Action View will use views from engines and other plugins.
h3. Documentation
@@ -56,7 +56,7 @@ Rails 2.3 should pass all of its own tests whether you are running on Ruby 1.8 o
h3. Active Record
-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.
+Active Record gets quite a number of new features and bug fixes in Rails 2.3. The highlights include nested attributes, nested transactions, dynamic and default scopes, and batch processing.
h4. Nested Attributes
@@ -126,6 +126,28 @@ Rails 2.3 will introduce the notion of _default scopes_ similar to named scopes,
* Lead Contributor: Paweł Kondzior
* More Information: "What's New in Edge Rails: Default Scoping":http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-default-scoping
+h4. Batch Processing
+
+You can now process large numbers of records from an ActiveRecord model with less pressure on memory by using +find_in_batches+:
+
+<ruby>
+Customer.find_in_batches(:conditions => {:active => true}) do |customer_group|
+ customer_group.each { |customer| customer.update_account_balance! }
+end
+</ruby>
+
+You can pass most of the +find+ options into +find_in_batches+. However, you cannot specify the order that records will be returned in (they will always be returned in ascending order of primary key, which must be an integer), or use the +:limit+ option. Instead, use the +:batch_size: option, which defaults to 1000, to set the number of records that will be returned in each batch.
+
+The new +each+ method provides a wrapper around +find_in_batches+ that returns individual records, with the find itself being done in batches (of 1000 by default):
+
+<ruby>
+Customer.each do |customer|
+ customer.update_account_balance!
+end
+</ruby>
+
+Note that you should only use this record for batch processing: for small numbers of records (less than 1000), you should just use the regular find methods with your own loop.
+
h4. Multiple Conditions for Callbacks
When using Active Record callbacks, you can now combine +:if+ and +:unless+ options on the same callback, and supply multiple conditions as an array:
diff --git a/railties/guides/source/layout.html.erb b/railties/guides/source/layout.html.erb
index f08bffd43c..cb02b90eb9 100644
--- a/railties/guides/source/layout.html.erb
+++ b/railties/guides/source/layout.html.erb
@@ -34,7 +34,7 @@
<p class="hide"><a href="#mainCol">Skip navigation</a>.</p>
<ul class="nav">
<li><a href="index.html">Home</a></li>
- <li class="index"><a href="#" onclick="guideMenu();" id="guidesMenu">Guides Index</a>
+ <li class="index"><a href="index.html" onclick="guideMenu(); return false;" id="guidesMenu">Guides Index</a>
<div id="guides" class="clearfix" style="display: none;">
<hr />
<dl class="L">