# Has many with multiple joins

**URL:** <https://www.ruby-forum.com/t/has-many-with-multiple-joins/91227>\
**Category:** Rails\
**Created:** [April 5, 2007, 8:01pm UTC](https://www.ruby-forum.com/t/has-many-with-multiple-joins/91227 "2007-04-05T20:01:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Kroman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Alex\_Kroman](https://www.ruby-forum.com/u/Alex_Kroman)\
**Post date:** [April 5, 2007, 8:01pm UTC](https://www.ruby-forum.com/t/has-many-with-multiple-joins/91227/1 "2007-04-05T20:01:20Z")

</div>

I have the following data model for a simple blog application. A user  
is in many groups and posts many entries. Every group displays the  
entries of everyone who is a member of that group.

# The models look like this:

User  
has\_many :memberships  
has\_many :groups, :through =\> :memberships

Memberships  
belongs\_to :user  
belongs\_to :group

Groups  
has\_many :memberships  
has\_many :users, :through =\> :memberships

Entries  
belongs\_to :user

===

My question is, what is the cleanest way to display a list of all the  
entries in a given group? I currently am using finder\_sql but I’m not  
sure if that is the cleanest way. Ideally I would be able to do  
something like group.entries or group.users.entries.

Any ideas?

---

<div class="post-metadata">

**Author:** ![Alex\_Kroman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Alex\_Kroman](https://www.ruby-forum.com/u/Alex_Kroman)\
**Post date:** [April 6, 2007, 3:24am UTC](https://www.ruby-forum.com/t/has-many-with-multiple-joins/91227/2 "2007-04-06T03:24:12Z")

</div>

I believe that Users needs a “has\_many :entries” to match the fact  
that Enties “belongs\_to :user”
