Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds STI (Single Table Inheritance) to our User model. There are two new classes introduced,
Teacher
andStudent
that both inherit from theUser
base class. One benefit of implementing STI on the User model is that it allows us organize the model along the axis ofuser_type
and move student and teacher specific logic into their respective classes.This functionality should not break existing usage. For example, you can continue to create a new user by calling
User.create(user_type: "Teacher")
. You can also now instead callTeacher.create()
, as STI provides additional class methods.This PR adds the following changes:
teacher.rb
andstudent.rb
and associated classestype
, this overrides that to beuser_type
find_sti_class
method overrideuser_builder.rb
Links
Testing story
You can test locally, and will be able to create new teacher and student accounts as before, as well as downgrade/upgrade account styles (Teacher -> Student, Student -> Teacher.
Deployment strategy
Follow-up work
Privacy
Security
Caching
PR Checklist: