From 041ee4ab2cf8f2db9bafbe324bc348bd300970ce Mon Sep 17 00:00:00 2001 From: Thor77 Date: Tue, 18 Jun 2019 18:33:24 +0200 Subject: [PATCH] Include bets in match resource --- app/controllers/matches_controller.rb | 2 +- app/serializers/match_serializer.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index ca5275d..778fca9 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -7,7 +7,7 @@ class MatchesController < ApplicationController # GET /matches/1 def show - render json: @match, include: ['match_scores.points', 'match_scores.team'] + render json: @match, include: ['match_scores.points', 'match_scores.team', 'bets'] end # PATCH/PUT /matches/1 diff --git a/app/serializers/match_serializer.rb b/app/serializers/match_serializer.rb index 28b7d1a..6b8d21f 100644 --- a/app/serializers/match_serializer.rb +++ b/app/serializers/match_serializer.rb @@ -7,5 +7,10 @@ class MatchSerializer < ApplicationSerializer ActiveModelSerializers::SerializableResource.new(object.winner).as_json end + def bets + ActiveModelSerializers::SerializableResource.new(object.bets, serializer: BetsSerializer).as_json + end + has_many :match_scores + has_many :bets end