From d24914c2e8f38a018b4855d65008d07b8ba8bb5b Mon Sep 17 00:00:00 2001 From: Kulbir Saini Date: Fri, 24 Sep 2010 04:27:51 +0530 Subject: Fixes in associations_basics guide. --- railties/guides/source/association_basics.textile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'railties/guides/source/association_basics.textile') diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index 3bf1c6295d..6996dab8c5 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -1029,7 +1029,7 @@ When you declare a +has_many+ association, the declaring class automatically gai * collection.empty? * collection.size * collection.find(...) -* collection.where(:conditions) +* collection.where(...) * collection.exists?(...) * collection.build(attributes = {}, ...) * collection.create(attributes = {}) @@ -1055,7 +1055,7 @@ orders.clear orders.empty? orders.size orders.find(...) -orders.where(:conditions) +orders.where(...) orders.exists?(...) orders.build(attributes = {}, ...) orders.create(attributes = {}) @@ -1134,15 +1134,15 @@ The collection.find method finds objects within the collection @open_orders = @customer.orders.find(:all, :conditions => "open = 1") -WARNING: Starting Rails 3, supplying options to +ActiveRecord::Base.find+ method is depricated. Use collection.where instead when you need to pass conditions. +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(: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. -@open_orders = @customer.orders.where(:open => 1) # No query yet -@open_order = @open_orders.first # Now the database will queried +@open_orders = @customer.orders.where(:open => true) # No query yet +@open_order = @open_orders.first # Now the database will be queried h6(#has_many-collection-exists). collection.exists?(...) @@ -1452,7 +1452,7 @@ When you declare a +has_and_belongs_to_many+ association, the declaring class au * collection.empty? * collection.size * collection.find(...) -* collection.where(:conditions) +* collection.where(...) * collection.exists?(...) * collection.build(attributes = {}) * collection.create(attributes = {}) @@ -1478,7 +1478,7 @@ assemblies.clear assemblies.empty? assemblies.size assemblies.find(...) -assemblies.where(:conditions) +assemblies.where(...) assemblies.exists?(...) assemblies.build(attributes = {}, ...) assemblies.create(attributes = {}) @@ -1564,9 +1564,9 @@ The collection.find method finds objects within the collection :conditions => ["created_at > ?", 2.days.ago]) -WARNING: Starting Rails 3, supplying options to +ActiveRecord::Base.find+ method is depricated. Use collection.where instead when you need to pass conditions. +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_and_belongs_to_many-collection-where). collection.where(:conditions) +h6(#has_and_belongs_to_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. It also adds the additional condition that the object must be in the collection. -- cgit v1.2.3