From d5c7257e75ba0d0fdd356fdb12e4be18e4701a30 Mon Sep 17 00:00:00 2001 From: capps Date: Mon, 11 Mar 2013 08:10:43 -0700 Subject: I think "uniq" is more Rails-y than select("distinct(categories.id)") --- guides/source/active_record_querying.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/active_record_querying.md') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 4a4f814917..e83c04d11e 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -970,7 +970,7 @@ SELECT categories.* FROM categories INNER JOIN posts ON posts.category_id = categories.id ``` -Or, in English: "return a Category object for all categories with posts". Note that you will see duplicate categories if more than one post has the same category. If you want unique categories, you can use `Category.joins(:posts).select("distinct(categories.id)")`. +Or, in English: "return a Category object for all categories with posts". Note that you will see duplicate categories if more than one post has the same category. If you want unique categories, you can use `Category.joins(:posts).uniq`. #### Joining Multiple Associations -- cgit v1.2.3