What I’m looking for is an appropriate way to set up a system where users can create projects and therefor become the admin of that project. The user can then add other admins to the project. Finally, other non-admin users can join the project.
I want to be able to verify whether a user is an admin of a project to check whether he has edit/update privileges. Any thoughts?
I figure I’ll probably have a users_projects table and a projects_admins table, but I can’t figure out how that translates to Rails relationships….
Thanks!
Ok, I will give it a try, but without too much code here in.
I see here 3 models:
The first 2 are simple models, with some attributes. The third one is the relation between the two and will be a n:m relation. So it is best to use the has-many-through relation here.
Of course you have to create additionally the 3 tables by migrations, and add later a similar relation for project users, named then
ProjectUseras model. Have at least a look at the rails guide about relations, section “has-many :through”.To add the creator to a project, this should be a one-one relation between the two, so it should be sufficient to have:
(and of course the
creator_idin the migration)