aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-08-31 00:01:41 +0100
committerPratik Naik <pratiknaik@gmail.com>2010-08-31 00:01:41 +0100
commit5a310f8335a407f2c95a84f1c73db20846370216 (patch)
tree0ca43250be489d8eefb5a9eeb8f839e362be14be /railties/guides/source
parent0bb32588b7e2badfa708271c0a743444abb76426 (diff)
downloadrails-5a310f8335a407f2c95a84f1c73db20846370216.tar.gz
rails-5a310f8335a407f2c95a84f1c73db20846370216.tar.bz2
rails-5a310f8335a407f2c95a84f1c73db20846370216.zip
Update the section about joins
Diffstat (limited to 'railties/guides/source')
-rw-r--r--railties/guides/source/active_record_querying.textile8
1 files changed, 4 insertions, 4 deletions
diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile
index 291989c30e..811f45d8b3 100644
--- a/railties/guides/source/active_record_querying.textile
+++ b/railties/guides/source/active_record_querying.textile
@@ -603,14 +603,14 @@ end
h3. Joining Tables
-<tt>Model.find</tt> provides a +:joins+ option for specifying +JOIN+ clauses on the resulting SQL. There are multiple ways to specify the +:joins+ option:
+Active Record provides a finder method called +joins+ for specifying +JOIN+ clauses on the resulting SQL. There are multiple ways to use the +joins+ method.
h4. Using a String SQL Fragment
-You can just supply the raw SQL specifying the +JOIN+ clause to the +:joins+ option. For example:
+You can just supply the raw SQL specifying the +JOIN+ clause to +joins+:
<ruby>
-Client.all(:joins => 'LEFT OUTER JOIN addresses ON addresses.client_id = clients.id')
+Client.joins('LEFT OUTER JOIN addresses ON addresses.client_id = clients.id')
</ruby>
This will result in the following SQL:
@@ -625,7 +625,7 @@ WARNING: This method only works with +INNER JOIN+,
<br />
-Active Record lets you use the names of the "associations":association_basics.html defined on the model as a shortcut for specifying the +:joins+ option.
+Active Record lets you use the names of the "associations":association_basics.html defined on the model as a shortcut for specifying +JOIN+ clause for those associations when using the +joins+ method.
For example, consider the following +Category+, +Post+, +Comments+ and +Guest+ models: