これらのモデルが与えられた場合:
App.TransportDocument = DS.Model.extend
number: DS.attr 'string'
date: DS.attr 'string'
printable_url: DS.attr 'string'
transport_document_rows: DS.hasMany('App.TransportDocumentRow')
App.TransportDocumentRow = DS.Model.extend
product_name: DS.attr 'string'
quantity: DS.attr 'number'
measure: DS.attr 'string'
transport_document: DS.belongsTo('App.TransportDocument')
ここに私のルートがあります:
App.TransportDocumentsRoute = Ember.Route.extend
model: -> App.TransportDocument.find()
App.TransportDocumentRoute = Ember.Route.extend
model: (params)-> App.TransportDocument.find(params.transport_document_id)
App.TransportDocumentRowRoute = Ember.Route.extend
model: -> App.TransportDocumentRow.find()
ハンドルバーのテンプレートがあります:
{{#each transport_document in controller}}
td_id: {{transport_document.id}}
{{#each transport_document_row in transport_document.transport_document_rows}}
row_id: {{id}}
{{/each}}
{{/each}}
私は私の結果が次のようになることを期待していました:
td_id: 1 row_id: 1 row_id: 2 row_id: 3
td_id: 2 row_id: 3 row_id: 4 row_id: 5
td_id: 3 row_id: 8 row_id: 7 row_id: 6
しかし、次のとおりです。
td_id: 1 row_id: row_id: row_id:
td_id: 2 row_id: row_id: row_id:
td_id: 3 row_id: row_id: row_id:
/transport_documents に対するサーバーの応答は次のとおりです。
{"transport_documents":
[
{"id":1,"number":"11","date":"17/04/2013","cause":"Conto lavorazione","transport_document_row_ids":[3,2,1],"transport_document_rows":
[
{"transport_document_row":{"id":3,"transport_document_id":1,"product_name":"suola puzzle verde","quantity":"1","measure":"pz","}},
{"transport_document_row":{"id":2,"transport_document_id":1,"product_name":"lacci rossi","quantity":"2","measure":"pz"}},
{"transport_document_row":{"id":1,"transport_document_id":1,"product_name":"Rotolo di tela","quantity":"50","measure":"m"}}
]},
{"id":2,"number":"2","date":"18/04/2013","cause":"Conto lavorazione","transport_document_row_ids":[6,5,4],"transport_document_rows":
[
{"transport_document_row":{"id":6,"transport_document_id":2,"product_name":"suola puzzle verde","quantity":"1","measure":"pz"}},
{"transport_document_row":{"id":5,"transport_document_id":2,"product_name":"lacci rossi","quantity":"2","measure":"pz"}},
{"transport_document_row":{"id":4,"transport_document_id":2,"product_name":"Rotolo di tela","quantity":"50","measure":"m",}}
]},
{"id":3,"number":"3","date":"19/04/2013","cause":"Conto lavorazione","transport_document_row_ids":[9,8,7],"transport_document_rows":
[
{"transport_document_row":{"id":9,"transport_document_id":3,"product_name":"suola puzzle verde","quantity":"1","measure":"pz"}},
{"transport_document_row":{"id":8,"transport_document_id":3,"product_name":"lacci rossi","quantity":"2","measure":"pz"}},
{"transport_document_row":{"id":7,"transport_document_id":3,"product_name":"Rotolo di tela","quantity":"50","measure":"m"}}]}
私はルートで何か間違ったことをしていると思います(そのドキュメントのすべての行を見つけるためのクエリをどこで定義しますか?)が、よくわかりません。ガイドでそのようなものを見つけることができません
ありがとうございました