Sprankelprachtig aan/afmeldsysteem

group.rb 686B

12345678910111213141516171819202122232425
  1. # A Group contains Members, which can organize and participate in Activities.
  2. # Some of the Members may be group leaders, with the ability to see all
  3. # information and add or remove members from the group.
  4. class Group < ApplicationRecord
  5. # @!attribute name
  6. # @return [String]
  7. # the name of the group. Must be unique across all groups.
  8. has_many :members
  9. has_many :people, through: :members
  10. has_many :activities
  11. validates :name,
  12. presence: true,
  13. uniqueness: {
  14. case_sensitive: false
  15. }
  16. # @return [Array<Member>] the members in the group who are also group leaders.
  17. def leaders
  18. self.members.includes(:person).where(is_leader: true)
  19. end
  20. end