我在网上找到的例子显示如下:
Flashcards.Subject = DS.Model.extend({
name: DS.attr('string'),
flashGroups: DS.hasMany('flashGroup', {async: true})
});
Flashcards.FlashGroup = DS.Model.extend({
name: DS.attr('string'),
subject: DS.belongsTo('subject')
});
然后按如下方式格式化JSON:
{"subject": {"id": 1, "name": "foo", "links": {"flash_groups": "/subjects/1/flash_groups"}}}
当我尝试sumSubject.get('flashGroups')时,没有任何反应。
答案 0 :(得分:0)
我相信有一个错误,links
键没有被贬低。尝试返回以下JSON:
{"subject": {"id": 1, "name": "foo", "links": {"flashGroups": "/subjects/1/flash_groups"}}}
(使用flashGroups
代替flash_groups
)