我使用此序列化程序使用字符串作为id,问题是当我这样做时,当我尝试使用HasMany关系时,我遇到了一个非常奇怪的错误:
TypeError: d is undefined @ localhost/ember-jsonmin/js/libs/ember-data.min.js:10
串行器:
App.TopologyminSerializer = DS.RESTSerializer.extend({
normalize: function(type, hash, property) {
// Ember Data use the zone name as the ID.
hash.id = hash.siteGroup;
// Delegate to any type-specific normalizations.
return this._super(type, hash, property);
}
});
App.SiteSerializer = DS.RESTSerializer.extend({
normalize: function(type, hash, property) {
// Ember Data use the zone name as the ID.
hash.id = hash.name;
// Delegate to any type-specific normalizations.
return this._super(type, hash, property);
}
});
型号:
App.Topologymin = DS.Model.extend({
siteGroup: DS.attr('string'),
sites: DS.hasMany('site')
});
App.Site = DS.Model.extend({
name: DS.attr('string'),
hosts: DS.attr()
});
答案 0 :(得分:1)
即使id是字符串,hasMany
关系仍然有效。错误是由其他东西触发的。
我在http://emberjs.jsbin.com/jomex/1/edit处使用您的代码制作了一个工作示例(使用ember 1.5.0和ember-data 1.0.0-beta.7)