5

I'm finding a good way to modeling User different types in the system. For registration, he/she can select to be a student, a mentor, or both. Being a student or a mentor has different set of properties. Student and mentor will have different profile template layout as well.

How would you design your controllers and models for this kind of problem?

1 Answer 1

3
  1. I would create a User which can hold a Mentor class and/or a Student class. This way your different properties are seperated from each other while the same properties still remain in the User class.
    In the Controller you can render a template (or partial), depending on the instance the User holds. One for students, one for mentors and one for both.

  2. You could also use Inheritance (User as parent with Mentor, Student and Both as childs). The key word you want to look into here is Single Table Inheritance.

Imho the problem is the both option. That's why I would prefer the 1st solution.

Sign up to request clarification or add additional context in comments.

1 Comment

The idea of a "Both" subclass feels incredibly awkward to me, unless the fact that someone is both somehow creates new properties. Definitely prefer your first solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.