Unique id in a find

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?



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

Thiago J.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs