aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/association_basics.textile
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-06-20 01:42:43 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2011-06-20 01:42:43 +0530
commit9513474e5e41458e641fb38176b956c2b80b9a0a (patch)
treee719b89841ac07a479a79e214689237520019b46 /railties/guides/source/association_basics.textile
parentd1b448ed3fe973957eef76c050278b0247db4764 (diff)
downloadrails-9513474e5e41458e641fb38176b956c2b80b9a0a.tar.gz
rails-9513474e5e41458e641fb38176b956c2b80b9a0a.tar.bz2
rails-9513474e5e41458e641fb38176b956c2b80b9a0a.zip
AR: use where in place of find
Diffstat (limited to 'railties/guides/source/association_basics.textile')
-rw-r--r--railties/guides/source/association_basics.textile4
1 files changed, 1 insertions, 3 deletions
diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile
index 458bfefad8..3c2497e83a 100644
--- a/railties/guides/source/association_basics.textile
+++ b/railties/guides/source/association_basics.textile
@@ -1120,11 +1120,9 @@ h6(#has_many-collection-find). <tt><em>collection</em>.find(...)</tt>
The <tt><em>collection</em>.find</tt> method finds objects within the collection. It uses the same syntax and options as +ActiveRecord::Base.find+.
<ruby>
-@open_orders = @customer.orders.all(:conditions => "open = 1")
+@open_orders = @customer.orders.where(:open => 1)
</ruby>
-NOTE: Starting Rails 3, supplying options to +ActiveRecord::Base.find+ method is discouraged. Use <tt><em>collection</em>.where</tt> instead when you need to pass conditions.
-
h6(#has_many-collection-where). <tt><em>collection</em>.where(...)</tt>
The <tt><em>collection</em>.where</tt> method finds objects within the collection based on the conditions supplied but the objects are loaded lazily meaning that the database is queried only when the object(s) are accessed.