Include bets in match resource

This commit is contained in:
Thor77 2019-06-18 18:33:24 +02:00
parent f3b8fd4184
commit 041ee4ab2c
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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