I’ll use an example to explain what behaviour I would like to achieve.
If you had a project management app and you added a task, but not all the contributors are users of the app.
So when you adding contributors to the task you can enter a user name or email address.
Here is the part that I’m finding a little tricky. The task model has many contributors which are linked through the user model, but from this point on I want to achieve 2 things.
-
Store the non members email(this would obviously be quite simple)
-
If that email address was to create an account it would then link that user to the task and remove the temporally saved email.
This way, when that user creates an account all the related tasks will already be associated with their email.
Is this something that i could achieve with a polymorphic association? or is there something else I should be looking at?
The part which involves polymorphic associations is many
taskshaving manycontributors.There are many ways to achieve the other functionality that you desire.
I would probably store the temporary email address by creating a new
contributorrecord without other the fields such as apassword. When the user actually signs up, I would use afirst_or_createmethod to complete setup of the user account.This removes the need for storing temporary emails and transferring task ownership. The same
idused to link acontributorto ataskbefore they sign up is the same one used after they sign up.