Include bets in match resource
This commit is contained in:
parent
f3b8fd4184
commit
041ee4ab2c
|
|
@ -7,7 +7,7 @@ class MatchesController < ApplicationController
|
||||||
|
|
||||||
# GET /matches/1
|
# GET /matches/1
|
||||||
def show
|
def show
|
||||||
render json: @match, include: ['match_scores.points', 'match_scores.team']
|
render json: @match, include: ['match_scores.points', 'match_scores.team', 'bets']
|
||||||
end
|
end
|
||||||
|
|
||||||
# PATCH/PUT /matches/1
|
# PATCH/PUT /matches/1
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,10 @@ class MatchSerializer < ApplicationSerializer
|
||||||
ActiveModelSerializers::SerializableResource.new(object.winner).as_json
|
ActiveModelSerializers::SerializableResource.new(object.winner).as_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bets
|
||||||
|
ActiveModelSerializers::SerializableResource.new(object.bets, serializer: BetsSerializer).as_json
|
||||||
|
end
|
||||||
|
|
||||||
has_many :match_scores
|
has_many :match_scores
|
||||||
|
has_many :bets
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue