Linking devise gem user model to student model and Teacher model

In my app, I want 2 different users(Student and Teacher) to login and I want the authentication be handled by devise.

So to my understanding, there is a User model generated by user
User Model:
username
password

Student Model:
student name
student ID
Grade…

Teacher Model:
Teacher name
Teacher subject…

How can I link the user model with Teacher model and Student model

I am thinking of using belongs_to and has_one association.
Student:
belongs_to :user

Teacher
belongs_to :user

User
has_one :student
has_one :teacher

How will this work?
Will user_id be a foreign key in Student table and Teacher table?

Also after a successful sign-up page(provided by devise), I want to redirect the user to Student form page or teacher form page based on the response from the user. How to implement that logic of asking the user whether they are student or teacher and then redirecting them to corresponding form page?

I know that devise does allow to redirect user to custom page ( after_sign_in_path_for) but I would like to show a dialog box from which the user can select where they want to go instead of another page.

Thank you

I would suggest giving your users roles, such as a teacher role and a student role. Based on their role, you can then redirect them to the desired route.