diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 461a67f..0f489fb 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,5 +1,6 @@ class GroupsController < ApplicationController def index - render jsonapi: Group.where(parent_id: nil), include: [children: [children: [:children]]] + roots = Group.where(parent_id: nil) + render jsonapi: roots, include: [children: [children: [:children]]] end end diff --git a/app/serializers/serializable_group.rb b/app/serializers/serializable_group.rb index e90dc52..f832475 100644 --- a/app/serializers/serializable_group.rb +++ b/app/serializers/serializable_group.rb @@ -4,4 +4,8 @@ class SerializableGroup < JSONAPI::Serializable::Resource attributes :name, :icon has_many :children + + attribute :guest_count do + @object.guests.count + end end