From b7a305f0cb7bf0cebc6f053b9faa45433809ce0d Mon Sep 17 00:00:00 2001 From: Rohit Arondekar Date: Sun, 13 Jun 2010 03:05:56 -0700 Subject: Rails Guides: AR Querying, .count should be at the end as it returns a number. [#4811 state:resolved] --- railties/guides/source/active_record_querying.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index e18dbc9c42..6e7ff6d5e0 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/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: -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 Which will execute: -- cgit v1.2.3