Topic: Drying up model duplication by subclassing?
I have an app that requires login authentication by 2 different types of users (Tutors and tutees) The models are not identical but they share a lot of common methods. My first thought was to have a parent model and create a subclass for each of the 2 types of user
class User < ActiveRecord::Base
# Lots of code to do authentication etc
class Tutor < User
# Code specific to tutor model
class Tutee < User
# Code specific to tutee model
This doesn't work as I anticipated. There needs to be a "users" table in the database and I don't want that, just tables for tutor and tutee.
Is this approach possible or do I need to resort to an include instead?
Last edited by soulflyer (2009-06-08 00:55:13)