This is a Rails app for a school. I'm using Devise for user accounts. So far each user has a .role
of admin
, teacher
or student
which restricts what the user can access and contribute in the app. I'm using user.email
to log in. All is working great so far.
Now I've realized that I have a problem with sibling accounts. The unique user.email
used for logging in is actually the parent's email address (since the students are minors) and now I have to account for a parent with two or more children who are students. I obviously can't have a student
account for each child and use the same email address because it has to be unique (and I do want to keep the requirement in the validation).
Given that I already have a large chuck of the app done, what would be a nice DRY way to account for this situation?
I've searched this site and others but not really found anything that accounts for this situation.
One way I thought would be to change the role in the User
model to parent and then have a separate Student
model . A user with the role of parent could then has_many :students
but this doesn't sit well with me.
Any general ideas/concepts would be appreciated, as would any pointers to articles or gems that would help me with this.