You can create different tables profileand just bind the profile to the user. Therefore, for each type of user, you can create a table and save certain information there and have a column user_idto return to users.
class User < ActiveRecord::Base
has_one :type_1
has_one :type_2
end
class Type1 < ActiveRecord::Base
belongs_to :user
end
class Type2 < ActiveRecord::Base
belongs_to :user
end
Now this is not very DRY and can lead to problems if you constantly add user types. So you can study polymorphism.
Polymorphism table usersdetermines the type of user ( profileable_idand profileable_type). So something like this:
class User < ActiveRecord::Base
belongs_to :profileable, :polymorphic => true
end
class Type1 < ActiveRecord::Base
has_one :user, :as => :profileable
end
class Type2 < ActiveRecord::Base
has_one :user, :as => :profileable
end
STI ( ) . , .