I\'m working on an app that has the models User
and Project
, and User
can be assigned to multiple Project
s, via Project
It sounds like what you're looking for is a combination of RoR's single table inheritance and named scopes.
Take a look at the following article for a nice example about polymorphic associations. This should help you with achieving the following:
@project.developers
# returns @project.users, but only where ProjectUser.role = 'Developer'
@project.designers << @user
# creates a ProjectUser for @project, @user with role 'Designer'
Scopes will give you a clean way to implement @user.development_projects
but there may be more trickery required to get the <<
operator.