From 28d047b1bf1576b8fd5737578fe65b800771ee26 Mon Sep 17 00:00:00 2001 From: Thor77 Date: Wed, 6 Nov 2019 15:57:03 +0100 Subject: [PATCH] Include parent group/stage in .index --- app/controllers/matches_controller.rb | 4 +++- app/serializers/extended_match_serializer.rb | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 app/serializers/extended_match_serializer.rb diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index cfa430b..71abf28 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -15,7 +15,9 @@ class MatchesController < ApplicationController m.state == match_params['state'] end end - render json: matches, each_serializer: MatchSerializer, include: '**' + render json: matches, each_serializer: ExtendedMatchSerializer, include: [ + 'match_scores.team', 'bets', 'stage', 'group' + ] end # GET /matches/1 diff --git a/app/serializers/extended_match_serializer.rb b/app/serializers/extended_match_serializer.rb new file mode 100644 index 0000000..8d96336 --- /dev/null +++ b/app/serializers/extended_match_serializer.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +class ExtendedMatchSerializer < MatchSerializer + belongs_to :group + belongs_to :stage +end