mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-31 17:09:07 +01:00
18 lines
396 B
Ruby
18 lines
396 B
Ruby
class Group < ActiveRecord::Base
|
|
belongs_to :user
|
|
has_many :group_members, dependent: :destroy
|
|
|
|
before_validation do
|
|
self.name = self.display_name.downcase.sub(/\s+/, '-')
|
|
end
|
|
|
|
alias members group_members
|
|
|
|
def add_member(user)
|
|
GroupMember.create! group: self, user: user
|
|
end
|
|
|
|
def remove_member(user)
|
|
GroupMember.where(group: self, user: user).first!.destroy
|
|
end
|
|
end
|