dwbutler / groupify

Add group and membership functionality to your Rails models
MIT License
194 stars 42 forks source link

Named Groups? (similar to GitHub organizations data model) #68

Closed blairanderson closed 6 years ago

blairanderson commented 7 years ago

Hi there!

Happy to close this issue if groupify doesn't handle but i figured this was pretty darn perfect.

My use-case:

User should be able to create a 2 teams named "rails" and "javascript". User should be able to be members of both as :admin or as a :collaborator

I see group name on the membership model but not sure how to prevents putting incorrect names on memberships.

joelvh commented 7 years ago

@blairanderson you want to add users with a membership type, right?

user.named_groups.add "rails", as: :admin
user.named_groups.add "rails", as: :collaborator
user.named_groups.add "javascript", as: :admin
user.named_groups.add "javascript", as: :collaborator

You can do any or all of the above.

dwbutler commented 6 years ago

The answer here is correct. There is nothing preventing you from putting the wrong group name in. It's up to your application to validate / whitelist group names.