diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-01-28 18:21:22 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-01-28 18:21:23 -0200 |
commit | 695ec8e2799a2c91f93a6fb58d713137a61aa0d2 (patch) | |
tree | 61cd049580a76cafc0974ea58a98a9003ff3a3c3 /railties/guides/source/association_basics.textile | |
parent | 856f13ab053f6b5dfa58d6e6c726d43cc5e73d00 (diff) | |
download | rails-695ec8e2799a2c91f93a6fb58d713137a61aa0d2.tar.gz rails-695ec8e2799a2c91f93a6fb58d713137a61aa0d2.tar.bz2 rails-695ec8e2799a2c91f93a6fb58d713137a61aa0d2.zip |
Improve active record associations guide a bit
* Use right example for has_many :find method;
* Reword has_many :counter_sql doc notes.
Diffstat (limited to 'railties/guides/source/association_basics.textile')
-rw-r--r-- | railties/guides/source/association_basics.textile | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index 451653655f..1b443e09a8 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -1120,7 +1120,7 @@ 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.where(:open => 1) +@open_orders = @customer.orders.find(1) </ruby> h6(#has_many-collection-where). <tt><em>collection</em>.where(...)</tt> @@ -1242,7 +1242,7 @@ h6(#has_many-counter_sql). +:counter_sql+ Normally Rails automatically generates the proper SQL to count the association members. With the +:counter_sql+ option, you can specify a complete SQL statement to count them yourself. -NOTE: If you specify +:finder_sql+ but not +:counter_sql+, then the counter SQL will be generated by substituting +SELECT COUNT(*) FROM+ for the +SELECT ... FROM+ clause of your +:finder_sql+ statement. +NOTE: If you specify +:finder_sql+ but not +:counter_sql+, then the counter SQL will be generated by substituting the +SELECT ... FROM+ clause of your +:finder_sql+ statement by +SELECT COUNT(*) FROM+. h6(#has_many-dependent). +:dependent+ |