开发者

Multiple User Logins in Rails

开发者 https://www.devze.com 2022-12-21 16:12 出处:网络
I am working on an app right now where I have Individuals, Athletes and Coaches. A coach has many athletes and they create athletes as well. Whereas individuals can just come to the site and use a dif

I am working on an app right now where I have Individuals, Athletes and Coaches. A coach has many athletes and they create athletes as well. Whereas individuals can just come to the site and use a different set of tools. So for functionality and logic reasons I prefer to keep the individual model separate from the athlete model.

When users come to the site I want them to login but it would be confusing to have 3 logins (coach, individual and athlete). Users coming to the site will get confused whether or not they are an individual or an athlete. I was thinking of putting a login link which would have an ajax menu with all three choices, which will look nicer but I still have the multiple login issue.

Does anyone have an idea on how I can make ideally 1 login form for individuals and athletes.开发者_JAVA百科 I am using authlogic for authentication. I am not looking for code, I can go in and mess around, just wondering if there is a trick to this (making it easier for the user).

Thanks!


You might want to look at the devise gem (http://github.com/plataformatec/devise), this supports using multiple models for authentication.


Why not have the Individual, Athlete and Coach models be subclasses of your User model. Then you can put all the authentication guff into User and it's available to all three - all through the same login form.


You want to assign Roles to Users. You don't need separate subclasses for each user type, model it so a user has_many :roles.

Have a look at this blog post for a detailed explanation - roles can be very simple if this is all you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消