# Unique id in a find

**URL:** <https://www.ruby-forum.com/t/unique-id-in-a-find/136716>\
**Category:** Rails\
**Created:** [May 5, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/unique-id-in-a-find/136716 "2008-05-05T21:16:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgjgjg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@jgjgjg](https://www.ruby-forum.com/u/jgjgjg)\
**Post date:** [May 5, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/unique-id-in-a-find/136716/1 "2008-05-05T21:16:15Z")

</div>

I’m trying to do something that seems easy but I can’t figure it out.  
I have Post.find(:all, :order =\> “created\_at desc”, :limit =\> 10)  
but if a user has a bunch of posts, I only want one of them to show up  
in the results so I have 10 posts with 10 unique user\_ids. I feel like  
distinct comes into play here somewhere.

Anyone have any thoughts on this?

thanks

J

---

<div class="post-metadata">

**Author:** ![jgjgjg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@jgjgjg](https://www.ruby-forum.com/u/jgjgjg)\
**Post date:** [May 6, 2008, 1:00am UTC](https://www.ruby-forum.com/t/unique-id-in-a-find/136716/2 "2008-05-06T01:00:53Z")

</div>

You can use distinct as you mentioned or ‘group by’ works too.

–  
Thiago J.  
[http://www.railsfreaks.com](http://www.railsfreaks.com)
