I’ve searched a bit before asking this but I definitely can’t get it working…
I’ve got a Group model which has a manager_id, a designer_id and other user ids corresponding to different user roles in this group. They are has_one User associations in the Group model with different foreign keys.
I’ve tried multiple belongs_to associations in the User model but… a User which belong to the group (they have a group_id column) can be one of these roles and I realy don’t know how to check these and how to do the associations in the User model.
Thank you in advance.
PS: The users can just belong to one group, that’s why I’ve simply put the group_id in the User model and not on a join table.
If being a manager or a designer in a group means that someone is a member if that group, there’s no way you can do this easily, you should create a membership model, that has a “role” property that says which role the user represents in a specific group, here’s how it would look like:
This gives you the functionality and even allow you to define as many roles for your groups as possible.