I’m working on a new app in Rails 3 but I’m not sure how can I build the relations between the models.
Basically I have a model User and a model Project. An user can create a Project, becoming the project owner. But any other user besides the project owner can join this project as well, but as team member.
Would I need to create a new model for this team relationship? And how would be the relations among this all?
Thanks in advance.
I’m doing something similar with a photo gallery that has shared permissions. Here is roughly the structure I’ve given it (though this is adapted from another project so may not be exactly right).
Basically, this allows a project to have both an owner that’s a user and a bunch of other members that are also users, and they can be accessed separately as such. These are related using a
has_many :throughrelationship, and we’re basically giving a more meaningful name than what the defaulthas_many :userswould give us.This also gives individual members the ability to join a project by creating a new
project_membershipobject for said project, while still maintaining a single owner.