A few months ago I decided to learn how to use Ruby on Rails, and after
learn some Ruby and do some projects by videotutoriales decided to start
my own project. Once I made a diagram of classes and relationships that
I need, I find my first problem:
I need multiple user profiles where to some types of users require more
information than others.
In addition to each type of user, once registered, will have different
home pages with different functions.
My intention is to make a polymorphic association from the User model,
generate by devise, containing the common attributes of all types of
users (email, name, password) to the models
user types (chef, singer, athlete, ...):
class User < ActiveRecord::Base
belongs_to :meta, :polymorphic => true
class Chef < ActiveRecord::Base
has_one :user, :as => :meta
According thought, the class of each user would be recorded at the time
of the registration, from the form devise registration view, by adding a
dropdown selector to choose a single type of user. And to log in, only
will be necessary the password and email, without the selector.
But I really have no idea of how to do this ( i don't know how enable
the selector to record the user class and do the appropriate
modifications to the controller Registrations devise or as a redirect to
different pages depending on the type of user who logs).
I ask for help if you have dealt with a similar problem, if you know
some way to do this, or if there is another easier way and efficient.
Sorry if I said a bad concept, but have little time using ruby on
rails and I'm a little lost and for my bad english!.
Thank you very much in advance and regards!
PS: I would avoid using gems, as camcam, for the many conditionals that
is necessary, that in my opinion, overload the system. I also read
concepts such as STI (singular table inheritance), but I thought it
would not be applicable here to store variable information for each type