> > class Team < ActiveRecord::Base > belongs_to :school > has_many :teachers > has_many :people, :through => :teachers > has_many :students > has_many :people, :through => :students > end
I'm pretty sure your has_many :people won't work, because you have two of them with different :through clauses. You would have to do something like: has_many :teacher_people, :class_name => 'People', :through => :teachers has_many :student_people, :class_name => 'People', :through => :students But as you can see, the naming gets awkward pretty quickly, as well as your database. It would be better to do as Colin suggested, and simply have a People table that contains all the teachers and students. If you really want separate classes for the teachers and students, you could use single table inheritance, but it may not be necessary. Then you could simple have a team_members table that linked your teams to people. class Team < ActiveRecord::Base belongs_to :school has_many :team_members has_many :members, :through => :team_members end class Person < ActiveRecord::Base scope :teachers, where(:person_type => 'Teacher') scope :students, where(:person_type => 'Student') end Then, you could get members, teachers, and students for teams like this: team.members team.members.teachers team.members.students Jim > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/q8i9PQr1BPAJ. For more options, visit https://groups.google.com/groups/opt_out.

