Forum: Ruby on Rails Has many with multiple joins

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D27847065560d2621ed4cd7aa4a234ce?d=identicon&s=25 Alex Kroman (Guest)
on 2007-04-05 20:01
(Received via mailing list)
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:
has_many :memberships
has_many :groups, :through => :memberships

belongs_to :user
belongs_to :group

has_many :memberships
has_many :users, :through => :memberships

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?
0c51049fb747cd60088e4878458e05d1?d=identicon&s=25 Rick Schumeyer (Guest)
on 2007-04-06 03:24
(Received via mailing list)
I believe that Users needs a "has_many :entries" to match the fact
that Enties "belongs_to :user"
This topic is locked and can not be replied to.