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?
on 2007-04-05 20:01
on 2007-04-06 03:24
I believe that Users needs a "has_many :entries" to match the fact that Enties "belongs_to :user"