A user has_many projects, a Project has_many Users, but each role is
associated with 1 user + 1 Project … i suggest to use has_many
:through and use a join table “project_meberships”
has_many :projects, :through => :project_memberships
has_many :users, :through => :project_memberships
the table “project_memberships” should look something like this:
id #primary key, auto increment
(additional fields like description)
This assumes you have pre-defined Roles like Admin, Teamleader,
Participant etc. pp. in the roles table.
@user = User.find(1)
role = @user.project_memberships(1).role
project = @user.project_memberships(1).project
You might want to read this about eager loading those associations with
a nested :include in the find command.