Please find how I would model a system that had teachers, students, classes and parents. Instead of creating a model for each user type, I created only two models, User and Profile. Each user can have multiple profiles and each profile can have a unique profile_type.I would love to get some feedback on my proposed architecture.class User < ActiveRecord::Base  has_many :profiles  has_many :user_klasses  has_many :klasses, through: :user_klasses  def get_student_classes    student_profile = profiles.select { |p| p.profile_type == 'student' }.first    return [] if student_profile.nil?    return klasses.select { |k| k.profile_id == student_profile.id }  end  def get_teacher_classes    teacher_profile = profiles.select { |p| p.profile_type == 'teacher'}.first    return [] if teacher_profile.nil?    return klasses.select { |k| k.profile_id == teacher_profile.id }  endendclass Klass < ActiveRecord::Base  has_many :user_klasses  has_many :users, through: :user_klasses  belongs_to :teacher, class_name: 'Profile', -> { where profile_type: 'teacher' },                        dependent: :destroyendclass UserKlasses < ActiveRecord::Base  belongs_to :user  belongs_to :klassendclass Profile < ActiveRecord::Base  belongs_to :userend
Class/model hierarchy for a school-management application
ruby;ruby on rails