Javascript 余烬数据多态关系:未使用正确的模型
尝试升级到2.0时使用旧版本的ember(1.7.1)和ember数据(1.0.0 beta 12)。加载应用程序时,我收到以下警告: 警告:“App.QPAC”的有效负载包含以下未知键:[abs\u parent\u gbid,author,comments,course,follow,has\u more\u comments,is\u announcement,more\u comments\u count,resource\u uri,title]。确保它们已在模型中定义 这是我的模型代码(除了post还有其他模型,但在这个实例中没有加载它们) Ember inspector向我展示了正在找到Post类型的所有feedstory对象,并且它在Post属性中显示正在加载正确的ID,但没有加载其他属性 警告说它正在App.QPAC模型中查找post属性,而不是App.post。有什么想法吗 编辑:添加了序列化程序和适配器Javascript 余烬数据多态关系:未使用正确的模型,javascript,ember.js,polymorphism,ember-data,Javascript,Ember.js,Polymorphism,Ember Data,尝试升级到2.0时使用旧版本的ember(1.7.1)和ember数据(1.0.0 beta 12)。加载应用程序时,我收到以下警告: 警告:“App.QPAC”的有效负载包含以下未知键:[abs\u parent\u gbid,author,comments,course,follow,has\u more\u comments,is\u announcement,more\u comments\u count,resource\u uri,title]。确保它们已在模型中定义 这是我的模型代
App.ApplicationAdapter = DS.RESTAdapter.extend({
namespace: 'api/v2'
});
App.FeedstorySerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
primaryKey: 'global_id',
attrs: {
pin: {embedded: 'always' },
story: {embedded: 'always'},
},
});
App.PostSerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
primaryKey: 'global_id',
attrs: {
author: {embedded: 'always' },
course: {embedded: 'always' },
pin: {embedded: 'always' },
comments: {embedded: 'always'},
follows: {embedded: 'always'},
},
normalize: function(type, hash, prop) {
if (Object.keys(hash.comments).length === 0) {
hash.comments = null;
}
if (Object.keys(hash.follows).length === 0) {
hash.follows = null;
}
return this._super(type, hash, prop);
},
});
您使用的是哪种适配器/序列化程序?@Lux更新了问题以显示序列化程序和适配器。
App.ApplicationAdapter = DS.RESTAdapter.extend({
namespace: 'api/v2'
});
App.FeedstorySerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
primaryKey: 'global_id',
attrs: {
pin: {embedded: 'always' },
story: {embedded: 'always'},
},
});
App.PostSerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
primaryKey: 'global_id',
attrs: {
author: {embedded: 'always' },
course: {embedded: 'always' },
pin: {embedded: 'always' },
comments: {embedded: 'always'},
follows: {embedded: 'always'},
},
normalize: function(type, hash, prop) {
if (Object.keys(hash.comments).length === 0) {
hash.comments = null;
}
if (Object.keys(hash.follows).length === 0) {
hash.follows = null;
}
return this._super(type, hash, prop);
},
});