I am using devise for my application authentication. I am having a User model which is the sign-in/up model.
The functionality is in such a way that when the client i.e. the user signs up, he’ll be taken to fill in the mandatory user-profile page. Everything worked fine using devise.
Now I have a new functionality, User can be of different types( lets say A, B,C)
If the user is of type A, then he has to follow the same sign up process and the same profile page.
If the user is of type B, then the sign up screen differs and awaits validation from administrator. Different changes for type C too.
All the different types have different profile pages and the fields differ.
So I decided to have a polymorphic association and this is 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 wanna know is this the right way to go about the scenario or is there an better way to implement this?
You want Rails’ magic
typecolumn.Update