Multiple User Accounts in Rails

Now I am working on an application where I have people, athletes and coaches. The trainer has many athletes and they also create athletes. While people can just go to the site and use a different set of tools. Therefore, for functional and logical reasons, I prefer to separately separate a separate model from the model of an athlete.

When users come to the site, I want them to log in, but it would be strange to have 3 inputs (trainer, person and athlete). Users who come to the site will be confused whether they are individuals or athletes. I was thinking about setting up a login link that has an ajax menu with all three options that will look better, but I still have a problem with multiple logins.

Does anyone have an idea how I can make the perfect 1 entry form for people and athletes. I use authlogic for authentication. I'm not looking for code, I can log in and chat, just wondering if there is a trick for this (which makes it easier for the user).

Thanks!

+4
source share
3 answers

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

+3
source

Why models of individuals, athletes and coaches are not subclasses of your user model. Then you can put all guff authentication in User and it is available for all three - all through the same login form.

0
source

You want to assign roles to users. You do not need separate subclasses for each type of user, model it so that the user has_many :roles .

Check out this blog post for a detailed explanation - roles can be very simple if that's all you need.

0
source

Source: https://habr.com/ru/post/1302592/


All Articles