Question

I am using this Serializers to use a string as the id, the problem is that when doing that, I have got a very strange error when I try to use the HasMany relation:

TypeError: d is undefined @ localhost/ember-jsonmin/js/libs/ember-data.min.js:10

Serializers:

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);
  }
});

Models:

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()
});
Was it helpful?

Solution

A hasMany relationship works even when ids are strings. The error is triggered by something else.

I made a working example with your code over at http://emberjs.jsbin.com/jomex/1/edit (using ember 1.5.0 and ember-data 1.0.0-beta.7)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top