Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend to deal with group managers/leaders? #3

Closed
cmcguff opened this issue Mar 24, 2014 · 3 comments · Fixed by #6
Closed

Extend to deal with group managers/leaders? #3

cmcguff opened this issue Mar 24, 2014 · 3 comments · Fixed by #6

Comments

@cmcguff
Copy link

cmcguff commented Mar 24, 2014

This is working great so far, how would I extend or use this to deal with managers or leaders of a group?

example - I am using named groups, if I add say 5 users to a group called :team1 how would I set one (or more) as managers of that particular group?

I'm not sure if the gem can handle this currently

@dwbutler
Copy link
Owner

Hi,

You're correct that the gem doesn't currently support this use case. It's one weakness of the relatively simple group membership concept: you're either a member, or you're not.

A simplistic solution to your problem would be to set the manager role or type on the user, and assume that a manager in a group is a manager of that group. This isn't a fully generic solution, because that would make the user manager of all groups they belong to, rather than just certain groups.

See the specs for examples of implementing this strategy using STI (Single Table Inheritance).

Probably the best solution would be to introduce a "membership type" concept. So in addition to being a member of a group, your membership could be of a certain type, i.e. nothing (the default), "manager", "employee", etc.

The simplest way to do this in ActiveRecord would be to add a new type column to the GroupMemberships join table. Then you could have multiple rows specifying each membership type that you have.

Doing this in Mongoid would be a bit more complicated. Mongoid stores relations as arrays of ids, and the named groups are stored as an array of symbols, on the member models. We could probably embed group membership types, at the cost of complicating the associated queries.

Let me know what you think about these proposed solutions.

@cmcguff
Copy link
Author

cmcguff commented Mar 24, 2014

I see - I think I prefer adding a type into the GroupMemberships, I'll have a look and see if I can make it work the way I want. Thanks.

@dwbutler dwbutler mentioned this issue Apr 7, 2014
@dwbutler
Copy link
Owner

dwbutler commented Apr 7, 2014

Please see te membership_type branch for an implementation for ActiveRecord. Please go to #6 for more updates on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants