My Rails application has users and tasks created by users. Users can also create a task and assign another user to it. I am not quite sure how to build associations here.
I know since a task is created by a user, I can have an association as below,
class User
  has_many :tasks, dependent: :destroy, foreign_key: :user_id
end
class Task
  belongs_to :user
end
I also want to add an association for creator in the Task model but I am not sure how to do it since a creator will also be an instance of the User class and I already have a belongs_to association with User
I tried to add an association for creator in Task model in the following way but it didn't work.
has_one :user, foreign_key: :creator_id, class_name: "User"