mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixes in associations_basics guide.
This commit is contained in:
parent
948248a23d
commit
d24914c2e8
1 changed files with 10 additions and 10 deletions
|
@ -1029,7 +1029,7 @@ When you declare a +has_many+ association, the declaring class automatically gai
|
||||||
* <tt><em>collection</em>.empty?</tt>
|
* <tt><em>collection</em>.empty?</tt>
|
||||||
* <tt><em>collection</em>.size</tt>
|
* <tt><em>collection</em>.size</tt>
|
||||||
* <tt><em>collection</em>.find(...)</tt>
|
* <tt><em>collection</em>.find(...)</tt>
|
||||||
* <tt><em>collection</em>.where(:conditions)</tt>
|
* <tt><em>collection</em>.where(...)</tt>
|
||||||
* <tt><em>collection</em>.exists?(...)</tt>
|
* <tt><em>collection</em>.exists?(...)</tt>
|
||||||
* <tt><em>collection</em>.build(attributes = {}, ...)</tt>
|
* <tt><em>collection</em>.build(attributes = {}, ...)</tt>
|
||||||
* <tt><em>collection</em>.create(attributes = {})</tt>
|
* <tt><em>collection</em>.create(attributes = {})</tt>
|
||||||
|
@ -1055,7 +1055,7 @@ orders.clear
|
||||||
orders.empty?
|
orders.empty?
|
||||||
orders.size
|
orders.size
|
||||||
orders.find(...)
|
orders.find(...)
|
||||||
orders.where(:conditions)
|
orders.where(...)
|
||||||
orders.exists?(...)
|
orders.exists?(...)
|
||||||
orders.build(attributes = {}, ...)
|
orders.build(attributes = {}, ...)
|
||||||
orders.create(attributes = {})
|
orders.create(attributes = {})
|
||||||
|
@ -1134,15 +1134,15 @@ The <tt><em>collection</em>.find</tt> method finds objects within the collection
|
||||||
@open_orders = @customer.orders.find(:all, :conditions => "open = 1")
|
@open_orders = @customer.orders.find(:all, :conditions => "open = 1")
|
||||||
</ruby>
|
</ruby>
|
||||||
|
|
||||||
WARNING: Starting Rails 3, supplying options to +ActiveRecord::Base.find+ method is depricated. Use <tt><em>collection</em>.where</tt> instead when you need to pass conditions.
|
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(:conditions)</tt>
|
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.
|
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.
|
||||||
|
|
||||||
<ruby>
|
<ruby>
|
||||||
@open_orders = @customer.orders.where(:open => 1) # No query yet
|
@open_orders = @customer.orders.where(:open => true) # No query yet
|
||||||
@open_order = @open_orders.first # Now the database will queried
|
@open_order = @open_orders.first # Now the database will be queried
|
||||||
</ruby>
|
</ruby>
|
||||||
|
|
||||||
h6(#has_many-collection-exists). <tt><em>collection</em>.exists?(...)</tt>
|
h6(#has_many-collection-exists). <tt><em>collection</em>.exists?(...)</tt>
|
||||||
|
@ -1452,7 +1452,7 @@ When you declare a +has_and_belongs_to_many+ association, the declaring class au
|
||||||
* <tt><em>collection</em>.empty?</tt>
|
* <tt><em>collection</em>.empty?</tt>
|
||||||
* <tt><em>collection</em>.size</tt>
|
* <tt><em>collection</em>.size</tt>
|
||||||
* <tt><em>collection</em>.find(...)</tt>
|
* <tt><em>collection</em>.find(...)</tt>
|
||||||
* <tt><em>collection</em>.where(:conditions)</tt>
|
* <tt><em>collection</em>.where(...)</tt>
|
||||||
* <tt><em>collection</em>.exists?(...)</tt>
|
* <tt><em>collection</em>.exists?(...)</tt>
|
||||||
* <tt><em>collection</em>.build(attributes = {})</tt>
|
* <tt><em>collection</em>.build(attributes = {})</tt>
|
||||||
* <tt><em>collection</em>.create(attributes = {})</tt>
|
* <tt><em>collection</em>.create(attributes = {})</tt>
|
||||||
|
@ -1478,7 +1478,7 @@ assemblies.clear
|
||||||
assemblies.empty?
|
assemblies.empty?
|
||||||
assemblies.size
|
assemblies.size
|
||||||
assemblies.find(...)
|
assemblies.find(...)
|
||||||
assemblies.where(:conditions)
|
assemblies.where(...)
|
||||||
assemblies.exists?(...)
|
assemblies.exists?(...)
|
||||||
assemblies.build(attributes = {}, ...)
|
assemblies.build(attributes = {}, ...)
|
||||||
assemblies.create(attributes = {})
|
assemblies.create(attributes = {})
|
||||||
|
@ -1564,9 +1564,9 @@ The <tt><em>collection</em>.find</tt> method finds objects within the collection
|
||||||
:conditions => ["created_at > ?", 2.days.ago])
|
:conditions => ["created_at > ?", 2.days.ago])
|
||||||
</ruby>
|
</ruby>
|
||||||
|
|
||||||
WARNING: Starting Rails 3, supplying options to +ActiveRecord::Base.find+ method is depricated. Use <tt><em>collection</em>.where</tt> instead when you need to pass conditions.
|
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_and_belongs_to_many-collection-where). <tt><em>collection</em>.where(:conditions)</tt>
|
h6(#has_and_belongs_to_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. It also adds the additional condition that the object must be in the collection.
|
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. It also adds the additional condition that the object must be in the collection.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue