I’m working on an application that allows users to generate university schedules and then edit them side-by-side with a friend.
The following 3 models exist in the app:
User
- has_many schedules
- has_many sidebysides
Schedule
- belongs_to user
- has_many sidebysides
SideBySide
- belongs_to user1
- belongs_to user2
- belongs_to schedule1
- belongs_to schedule2
The parent-child relationships look as follows:
User IS PARENT OF schedules, sidebysides
Schedule IS PARENT OF sidebysides AND IS CHILD OF user
SideBySide IS CHILD OF user1, user2, schedule1, schedule2
I have a feeling I’m approaching this wrong. How might I create the relationships explained above?
Something like:
You can’t do
belongs_to user1sinceuser1is an instance ofUser. Same applies to Schedules