マッチのリストを取得するだけでなく、関連付けられている各プレイヤーのオブジェクトも取得するように Ember に指示するにはどうすればよいですか?
私のルーターには、次のものがあります。
App.MatchesRoute = Ember.Route.extend
model: ->
App.Match.find()
これが私のJSONデータの目的ですlocalhost:3000/matches.json
{"matches":[{"id":1,"player_one":{"id":1,"name":"Lex"},"player_two":{"id":20,"name":"Superman"}}]}
2013 年 3 月 15 日より詳細な情報を提供するための更新
これがmatches.emblem
(エンブレムはhaml-slim-like-handlebarsです)
#matches
each match in controller
linkTo "match" match class="panel six columns"
p Match between {{match.player_one.name}} and {{match.player_two.name}}
Match
オブジェクトの取得に成功し、その上で を呼び出すことができますが (表示されていません)、 undefined を返すおよびid
の名前を取得する必要があります。match.player_one
match.player_two
マッチ
App.Match = DS.Model.extend
player_one: DS.belongsTo('App.Player')
player_two: DS.belongsTo('App.Player')
プレーヤー
App.Player = DS.Model.extend
name: DS.attr('string')