From: John Goetz Date: 2008-11-11T00:08:26+09:00 Subject: Re: design advice for newbie Brian Candler wrote: > This sounds fine to me, but for an alternative approach you could > consider Single Table Inheritance. That is, you have separate classes > for Student, Parent, Teacher etc, but they all live in the users table, > and can all be considered as a User. Teacher.find(...) will > automatically be restricted to User.find(:conditions => > "type='Teacher'") > > http://ar.rubyonrails.com/classes/ActiveRecord/Base.html > > Scroll down to "Single table inheritance" Also, the book "Agile Web > Development with Rails" has a section on this (but don't buy the 2nd > edition now, wait for the 3rd edition due in December) > > However as already mentioned, this may be a Bad Idea. It's quite > possible for the same person to be both a student and a parent, or a > teacher and a trustee. > > Person.has_and_belongs_to_many :roles may be a better way of modelling > this. Admittedly the SQL finders get a bit more awkward. Thanks, Brian, for the direction. With Todd's advice also, I will investigate how to write up the has-and-belongs-to-many relationship and single table inheritance. I already pre-purchased the 3rd edition of Agile Development with Rails and have a PDF of the beta release. It's helped me a lot, but I didn't get to that section yet. Time to hit the book again! -- Posted via http://www.ruby-forum.com/.