Currently I am working on a app, so far I have User (with devise) which are able to create projects. So, if user1 create project A and project B I want him, to be able to assign user2 with role admin on project A, and user2 with moderator admin on project B.
I was thinking in creating a UserRoleProject link table, is it a good idea? Also I intend to use CanCan for the authorisation.
Currently I am working on a app, so far I have User (with devise) which are able to create projects. So, if user1 create project A and project B I want him, to be able to assign user2 with role admin on project A, and user2 with moderator role on project B.
I was thinking in creating a UserRoleProject link table, is it a good idea? Also I intend to use CanCan for the authorisation.
Thinking more about this, I realised that I should have the fallowing associations. User has_many Projects, Project belongs_to User, User has_many UserRole, UserRole belongs_to User, Projects has_many UserRole, UserRole belongs_to Project, Role has_many UserRole, UserRole belongs_to Role, is this right?
Thinking more about this, I realised that I should have the fallowing
associations. User has_many Projects, Project belongs_to User, User has_many
UserRole, UserRole belongs_to User, Projects has_many UserRole, UserRole
belongs_to Project, Role has_many UserRole, UserRole belongs_to Role, is
this right?
That should work, however if you had a role of Creator or Owner then
you could also setup the creation through the link table and would not
need the direct association between user and projects.