Permalink
Browse files

Rails Guides: AR Querying, .count should be at the end as it returns …

…a number. [#4811 state:resolved]
  • Loading branch information...
1 parent 27f337d commit b7a305f0cb7bf0cebc6f053b9faa45433809ce0d @rohit rohit committed Jun 13, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 railties/guides/source/active_record_querying.textile
@@ -869,7 +869,7 @@ SELECT count(*) AS count_all FROM clients WHERE (first_name = 'Ryan')
You can also use the +includes+ or +joins+ methods for this to do something a little more complex:
<ruby>
-Client.count.where("clients.first_name = 'Ryan' AND orders.status = 'received'").includes("orders")
+Client.where("clients.first_name = 'Ryan' AND orders.status = 'received'").includes("orders").count
</ruby>
Which will execute:

0 comments on commit b7a305f

Please sign in to comment.