I have 3 kinds of users in my application: Club, Person and Admin . Each of them is very different from each other, which means that they hardly use any attributes except authentication data, so I would prefer to use 3 different models . In addition, I want to enable a single authentication model for all these types of users using Authlogic and handle authorization using CanCan .
Initially, I thought of something like that.
class User < ActiveRecord::Base
And for each of them I would have
class Club < User end class Admin < User end
But then the User table will be cluttered with all columns of other types of users, and they will remain empty.
Another variant:
class User < ActiveRecord::Base
And for each type of user a role will be assigned. The problem is that accessing the method properties will be something like user.role.logo
. One way I can think of is to solve this using a delegate, but still I don't know if this is the best option.
The question is, how would you suggest me to implement this? What would be the best way?
acadavid
source share