Requirements
A group can have multiple group owners .
Active members can become group owners.
A group owner can add and remove himself and other members as/from owners .
A group owner can cancel his own membership and other owner’s membership aswell .
Present Design
Implementation
Approach
Model Level Changes
The following methods were added in groups model to handle addition and removal of group members as owners .
add_as_owner
Updates the is_owner column of membership record to true.
remove_as_owner
Updates the is_owner column of membership record to false.
The following columns are added in existing tables :
Table name - group_membership
| Column_name | type | Description |
| is_owner | boolean | when set indicates a member with owner privilege and when unset indicates a normal group member |
Associations modified :
User model :
has_many :owned_groups, :through => :memberships , :source => :group , :conditions => ['is_owner = ?',true], :foreign_key => 'user_id'
Work Flow
Once a user creates a group , the membership record is created with the is_owner flag set to true .
An owner has the privilege to add other active members as owners or remove them from the owner list .
If a member is already a member of the group the 'Add to group owners' link changes to 'Remove from group owners'.
If the member is the only owner of the group , the 'Cancel' and 'Remove from group owners' links are disabled for him.
Owner being a group member also gets enrolled in the In Person Events → auto enroll option.
Note