I am using an application authentication program. I have a User model that is an input / output model.
The functionality is that when the client, that is, the user subscribes, he will be busy to fill out the page of the required user profile. Everything worked perfectly through development.
Now I have new functionality. The user can be of different types (say A , B , C )
If the user is of type A , he must follow the same registration process and the same profile page.
If the user is of type B , then the registration screen is different and awaits confirmation from the administrator. Various changes for type C too.
All different types have different profile pages, and the fields are different.
So, I decided to have a polymorphic association, and that's exactly how my models look.
class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable attr_accessible :email, :password, :password_confirmation, :remember_me belongs_to :user_type, :polymorphic => true end class A has_one :user, :as => :user_type end class B has_one :user, :as => :user_type end class C has_one :user, :as => :user_type end
I just want to know that this is the right way to go the script or is there a better way to implement this?