Search code examples
ruby-on-railsmodelconceptual

Setting up models for tutor website


I'm wondering what the best way would be to set up models in Ruby on Rails for a tutoring website.

I would like the users to register (I have no particular way in mind but I'm assuming I'll go with one of the more popular ruby gems). They can then choose to be either tutors or students or both. Should I make a tutors model, a students model and have them inherit basic info from the authentication? Or would it be better to have a users model where all the basic info goes (birthday, gender) and then have student/tutor inherit from that?


Solution

  • I think it is better for Student and Tutor to inherit from your User model. You can choose to still keep the data in the same database table using STI in rails.

    This approach will ensure that there is a clear separation of responsibility in your domain, while re-using the same authentication (and later authorization) flow.