Rails app using Devise for user authentication. Started simple, now getting quite complex.
There are 3 kinds of user that will be logging in to the site: Admin, Teacher, Parent. I have a single Devise User
model and User.role
string for these. There is a Student
model (which doesn't log in) and a Lesson
model.
These are the relationships I need:
- Lesson belongs to one Student
- Student has many Lessons
- Student has many Teachers
- Student belongs to one Parent
- Parent has many Students
- Teacher has many Students
Basic functionality of the site: Teachers log in and make lessons for their students. Parents log in and see all lessons for their kids (students). Admins log in and can CRUD teachers, parents and students.
I have most of it working but got stumped when I tried to implement 'student has many teachers' and 'parent has many students'. My initial (incorrect) assumptions were that a student only has one teacher and that a parent just has one child at the school.
So it seems that using a User.role
string won't suffice for these relationships.
Any advice or general concepts would be greatly appreciated.