我有两个模型 - 会话和测试(余烬数据)
会话has_many测试。
问题在于,从服务器返回的JSON(无法更改)在会话对象中没有test_ids,因此我无法在模型中使用它。
我希望能够在进入#/ session / 4时让ember对<server_address>/rest/sessions/4/tests
进行另一次服务器API调用并将其置于“tests”属性中
当前代码:
App.Session = DS.Model.extend({
logicalId: DS.attr('string'),
.....
// tests: DS.hasMany('test', {async: true}) - wish I could do this
});
App.SessionSerializer = DS.ActiveModelSerializer.extend({
normalizePayload: function(payload) {
payload.sessions = payload.result;
delete payload.error;
delete payload.result;
delete payload.metadata;
return payload;
}
});