From 9513474e5e41458e641fb38176b956c2b80b9a0a Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Mon, 20 Jun 2011 01:42:43 +0530 Subject: AR: use where in place of find --- railties/guides/source/association_basics.textile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'railties') 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). collection.find(...) The collection.find method finds objects within the collection. It uses the same syntax and options as +ActiveRecord::Base.find+. -@open_orders = @customer.orders.all(:conditions => "open = 1") +@open_orders = @customer.orders.where(:open => 1) -NOTE: Starting Rails 3, supplying options to +ActiveRecord::Base.find+ method is discouraged. Use collection.where instead when you need to pass conditions. - h6(#has_many-collection-where). collection.where(...) The collection.where 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. -- cgit v1.2.3