I have a many-to-many relationship between User and Task model.
A task can have many users, but it should keep track of its original creator (if a user creates one by @user.tasks.create). I was wondering how could I do this.
I would have to create a new column field called “creator” in the tasks table. I could then initalise a task in the following way:
@user.tasks.create(:creator=>@user)
Is there a way of not having to add the arguments since the creator will always be the user that instantiated the task.
Thanks!
EDIT
My User model has:
has_many :taskization
has_many :tasks, :through => :taskization
My Tasks model has:
has_many :taskization
has_many :users, :through => :taskization
it sounds like you’re indicating that the ‘original_creator’ is an attribute of the Task. For each Task record, you want to keep track of which User originally created it.
So, modeling that seems like you would require both:
as well as
to work.
This requires two different relationships between
Taskobjects andUserobjects.Notice that the ‘creator’ relationship is not a
:throughtask, it’s a relationship directly between the two objects.