Hi, Newbie here. I'm having to enter this from memory since my work is on a closed network, so forgive any syntax errors.
I'm trying to recreate some basic Google Plus functionality with regards to users, posts, and circles - that is, a user can see a post only if he/she is in one or more of the same circles that the post belongs to: class User has_and_belongs_to :circles has_many :posts class Post has_and_belongs_to :circles belongs_to :user # the user that created the post class Circle has_and_belongs_to :posts has_and_belongs_to :users Given the above, how can I retrieve all posts viewable by a user? The SQL (I think) would be: select distinct p.id from posts p, circles_posts cp, circles_users cu where p.id = circles_posts.post_id and cp.circle_id = cu.circle_id and cu.user_id = current_user.id I also need to be able to retrieve posts related to a subset of circles to which the user belongs: select distinct p.id from posts p, circles_posts cp, circles_users cu where p.id = circles_posts.post_id and cp.circle_id = cu.circle_id and cu.circle_id in (4,5,6) and cu.user_id = current_user.id Can someone help? I can handle the basic RoR associations but this one is making my brain explode. :) Thanks _very_ much, Stan McFarland -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

