You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a group where each member has a membership_type. When a given user looks up their groups Id like to show them the other users in that group but I want to restrict it based on the current user's membership_type.
For example, a group 'owner' can see all members where as an 'editor' can only see other editors.
Is there a standard approach to something like that?
I've mucked around and come up with this but I'm not sure if its the best approach:
Currently there isn't any standard API for querying for group membership types, or filtering members by shared membership type. I think it makes sense to add these. It may be sufficient to add a single method, GroupMember#group_membership_types(group), which would return all the membership types for a member in a given group.
For now, it looks like your solution probably works for your specific use case. Consider however that in the general case, a member may have multiple membership types in a single group, and a group may have multiple types of members. So consider using this modified version:
This will correctly query all membership types in the general case. It should also generate a single query with a subquery, instead of running two queries.
Hey - great work on this gem!
I have created a group where each member has a
membership_type
. When a given user looks up their groups Id like to show them the other users in that group but I want to restrict it based on the current user's membership_type.For example, a group 'owner' can see all members where as an 'editor' can only see other editors.
Is there a standard approach to something like that?
I've mucked around and come up with this but I'm not sure if its the best approach:
Thanks!
The text was updated successfully, but these errors were encountered: