Permalink
Browse files

I think "uniq" is more Rails-y than select("distinct(categories.id)")

  • Loading branch information...
1 parent b938f08 commit d5c7257e75ba0d0fdd356fdb12e4be18e4701a30 capps committed Mar 11, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 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

0 comments on commit d5c7257

Please sign in to comment.