So in my case, I have a Project
and Client
model, and they have a have_and_belongs_to_many
association between each other, as shown below:
# app/models/client.rb
class Client < ApplicationRecord
has_and_belongs_to_many :projects
end
# app/models/project.rb
class Project < ApplicationRecord
has_and_belongs_to_many :clients
end
However, I would also like to include another field in Project
that associates an original Client
that essentially owns that project, but is sharing it with other Clients.
Through a has_and_belongs_to_many
association in the very basic way, I can't really see how to do this. I thought about adding another field in the model called owner_client_id
, but I'm not sure if this goes against best practices or if it's not recommended, etc.
Is there any way that I can still make this association?