How do I find all responses that a user has had to all of their posts
obviously
User.find(1).posts.responses fails since posts returns an array of
post objects
I could use User.find(1).posts.map{|p| p.responses}.flatten but this
seems messy. I’m sure there must be a better (more rails) way of doing
this. Has anybody got any suggestions?
post
User.find(1).posts.responses fails since posts returns an array of
post objects
I could use User.find(1).posts.map{|p| p.responses}.flatten but this
seems messy. I’m sure there must be a better (more rails) way of
doing
this. Has anybody got any suggestions?
Thanks for the replies. I especially like the through method, which I
have used before but usually in a way to link say for example user ←
membership → group. I hadn’t thought of using it in this way. How far
can this be extended? Sy giving the silly example that there are sub-
responses (responses has_may sub_responses) is there a way to link the
user to the sub_responses with another through such that I can use
User.find(1).sub_responses?