Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMostafa Elsayed
2,336 PointsMultiple model authentication with devise
Hey guys,
I'm running into problems with my app, I'm trying to create an app that has 4 different types of users and each user has 3-4 common attributes and 4-5 completely different ones. How can I get to authenticate them with devise?
Do i generate a devise model for each? And every model should also have a profile thats unique to the type of profile, advise would be greatly appreciated.
Thanks.
5 Answers
Jason Seifer
Treehouse Guest TeacherHi Mostafa Elsayed this is a pretty complex question. You may want to use some topics we haven't covered such as STI or RBAC to accomplish this but it's really tough to say without knowing a lot about your application. Check out the cancan gem and this wiki page for more info (https://github.com/ryanb/cancan/wiki/Role-Based-Authorization).
Mostafa Elsayed
2,336 PointsHey @Jasonseifer, Thanks for the reply! I was looking into cancan and STI as well, I will have to try them out to see if can use them with my application. So far tho it's an application where there are 4 different types of users, they all have the personal info attributes in common but the should all have different views, example would be artists, listeners, guests and event coordinators. Every role would have a completely different view and actions! Let me know what you think.
Jason Seifer
Treehouse Guest TeacherHey Mostafa Elsayed you can definitely use one model for all different types of users and differentiate based on a database field. You can then use join tables for the extend information. At that point you can redirect to different views and actions depending on the role of the user.
Mostafa Elsayed
2,336 Points@jasonseifer I think I will play around with that and I will try some other things I have in mind, I will keep you posted as to how it goes! Thanks for the help Jason
Mostafa Elsayed
2,336 Points@jasonseifer I think I will play around with that and I will try some other things I have in mind, I will keep you posted as to how it goes! Thanks for the help Jason