Return number of guests per group
This commit is contained in:
		
							parent
							
								
									cca869a0c4
								
							
						
					
					
						commit
						de93ffb643
					
				| @ -1,5 +1,6 @@ | |||||||
| class GroupsController < ApplicationController | class GroupsController < ApplicationController | ||||||
|   def index |   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 | ||||||
| end | end | ||||||
|  | |||||||
| @ -4,4 +4,8 @@ class SerializableGroup < JSONAPI::Serializable::Resource | |||||||
|   attributes :name, :icon |   attributes :name, :icon | ||||||
| 
 | 
 | ||||||
|   has_many :children |   has_many :children | ||||||
|  | 
 | ||||||
|  |   attribute :guest_count do | ||||||
|  |     @object.guests.count | ||||||
|  |   end | ||||||
| end | end | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user