Hello! I'm new here. I'm currently working on an app and I'm trying to wrap my mind around how I want to handle authentication using Devise. I've read the past threads that were similar to my situation but I figured I'd ask anyways since I'm still a bit confused.
The overall purpose of the app is for two different types of users (ex. student or teacher) to communicate with each other through messaging (granted that they have both added each other to their networks).
I would like to have someone sign up, decide what type of user they are (ex. student or teacher), and depending on which one they choose they would have to fill out specific profile information relevant to that type of user via a redirect once the user has been created. Students and teachers have different types of profiles they need to fill out.
I would like to have people sign in using one form if possible, and have the form know which type of user just logged in and redirect them to the dashboard view associated with that type of user.
For the sake of the user example, student and teachers have different pages they can access that are unique to their user.
If there are any questions about what I'm trying to do here, feel free to ask and I'll clarify.
The simplest way to go about this is probably to create just one User type but add a role attribute to it. Just make it a string to keep it simple. When you sign up, you can choose either Student or Teacher. Depending on hwich one you select, submit the string "student" or "teacher" for the role field so it can get saved to the database.
You can use that role attribute to redirect them easily. Then you can have to different types of profiles in your database. StudentProfile, and TeacherProfile. You can put any of the fields you want to have on those, and then ask them to fill out the correct type of profile after signing up based on their role.
Let me know how it works out!
Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.