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

Groupify support unique groups scoped to user? #18

Closed
lstone opened this issue Nov 7, 2014 · 2 comments
Closed

Groupify support unique groups scoped to user? #18

lstone opened this issue Nov 7, 2014 · 2 comments

Comments

@lstone
Copy link

lstone commented Nov 7, 2014

Can I use groupify to create user owned groups that are only accessible to the owners? For example, a Facebook user can create a user group and assign friends to that group, but others cannot see this group. Is this easily done with Groupify?

Please explain - an example would be fantastic, time permitting.

@dwbutler
Copy link
Owner

dwbutler commented Nov 8, 2014

I suppose you can use membership types to add one user to the group as "owner" and the others as "friends". You can then use authorization rules so that only the owner can view the group.

# Set up the group
group=Group.create!
group.add(owner, as: 'owner')
group.add(owner.friends, as: 'friend')

# Retrieve the group
group = owner.groups.as('owner')
friends = group.users.as('friend')

# Restrict access
current_user.in_group?(group, as: 'owner')

@lstone
Copy link
Author

lstone commented Dec 9, 2014

Thank you very much!

@lstone lstone closed this as completed Dec 9, 2014
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

No branches or pull requests

2 participants