1 year ago

Create models "on the fly" before its parent model is saved

Posted 1 year ago by gabrielereremita

I've been having this question for quite a long time. I guess it's more of a design problem. So I need to create an User with a mentor role that has many tutorships, but in the create user view I want to be able to add as many tutorships as I want. Once the tutorships are created, I want to be able to perform CRUD operations on them. However, I want to be able to do this before actually saving its parent model (User) in the database. What is the common approach here? Am I supposed to create and then persist each Tutorship with an empty foreign key until I save the user? Or is it better if all the Tutorships are "floating around" until I save my user? Any help would be really appreciated, thank you!

Please sign in or create an account to participate in this conversation.