I did the polymorphic approach, but the project died and never quit
got it right. Since then I've been using model that inherit User,
mainly because the data (name, address etc) were about the same
http://groups.google.com/group/plataformatec-devise/browse_thread/thread/bbc3bb0e245ad4d3/f4667ffce8faadec?lnk=gst&q=polymorphic#f4667ffce8faadec
If there a lot of differences, the polymorphic is really fairly easy.
If you don't try to mix nested attributes you can use the same
approach used on inherited Users. Just put a link in the Teacher
profile (whatever the can update) to the devise user edit.
Some chuck of code from a couple different system:
class User < ActiveRecord::Base
belongs_to :loginable, :polymorphic => true
....
class Employee < ActiveRecord::Base
belongs_to :office
has_many :projects
has_one :user, :as => :loginable
application controller clip (replace user_type with loginable_type for
polymorphic)
def after_sign_in_path_for(resource_or_scope)
#scope = Devise::Mapping.find_scope!(resource_or_scope)
case current_user.user_type
when "admin"
user_session[:namespace] = current_user.user_type
return admin_welcome_index_path
when "company"
user_session[:namespace] = current_user.user_type
return company_welcome_index_path
when "project"
user_session[:namespace] = current_user.user_type
return project_welcome_index_path
when "citizen"
user_session[:namespace] = current_user.user_type
return citizen_welcome_index_path
else
user_session[:namespace] = 'citizen'
super
end
end
Hope it give you a start.
Steve