I can't solve my problem for already a week.
I have 4 models: Person, Position, Workspace, and Phonenumber.
The hierarchy is Person > Position > Workspace > Phonenumber.
A chain of all 4 models is unique. Say, there may be only one man:
Person | Position | Workspace | Phonenumber |
Smith Engineer Department #4 555-666
But there may be another man with the same Position, Workspace, and Phonenumber:
Person | Position | Workspace | Phonenumber |
Johnson Engineer Department #4 555-666
Or even the same Mr. Smith, but different position or workspace.
Person | Position | Workspace | Phonenumber |
Smith Engineer Department #7 555-666
And so on.
All 4 at the same time are unique.
I want to store this data. I tried many different things. Nothing helped me at 100%. For now my best idea is to use has_many through relationships with join model called Employee:
person_id | position_id | workspace_id | phonenumber_id
But how do I work with data?
Say, I want to create new person with some position, workspace and phonenumber. How do I do that?