I’m trying to wrap my head around how to do self referencing associations in Phoenix. I have done this in Rails but now am trying to do the same in Phoenix.
Basically the setup is like this:
I have a lot of Users that can all login, but have different roles. It is a teaching app, so the main roles are student and teacher. A teacher has_many students and a student belongs_to a teacher. But these are both in the Users table. hence the self-referencing association.
Can someone point me to the right direction in setting this up? It seems that it is a pretty common thing so just wondering if there are any best practices to do this.