As the title states, I would like to know, before writing a join, if there is a way to write this query in rails.
I need to find every topic which has one post from user XXX.
What are the approach that is considered “correct” for this type of query in rails?
Edit 1:
My models are these actually:
- Topic has_many Comment
- Comment belongs_to User
- Comment belongs_to Topic
- User has_many Comment
- User has_many Topic
Try this: