Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember Data cannot read property 'async' of undefined

Using Ember v1.8 beta 3+ with Ember Data 1.0 beta 10- you receive this error:

Error while processing route: index Cannot read property 'async' of undefined TypeError: Cannot read property 'async' of undefined
    at Relationship [as _super$constructor] (http://builds.emberjs.com/canary/ember-data.js:9523:46)
    at new BelongsToRelationship (http://builds.emberjs.com/canary/ember-data.js:9736:12)
    at createRelationshipFor (http://builds.emberjs.com/canary/ember-data.js:9840:16)
    at http://builds.emberjs.com/canary/ember-data.js:6366:41
    at http://builds.emberjs.com/canary/ember-data.js:9307:20
    at cb (http://builds.emberjs.com/ember-latest.js:15907:13)
    at OrderedSet.forEach (http://builds.emberjs.com/ember-latest.js:15703:13)
    at Map.forEach (http://builds.emberjs.com/ember-latest.js:15911:19)
    at Function.Model.reopenClass.eachRelationship (http://builds.emberjs.com/canary/ember-data.js:9306:42)
    at Ember.Object.extend._setup (http://builds.emberjs.com/canary/ember-data.js:6365:26) 

Despite your models being set up correctly:

App.Color = DS.Model.extend({
  color: DS.attr(),
  foo: DS.belongsTo('foo', {async:true})
});


App.Foo = DS.Model.extend({
  foo: DS.attr()
});

Example: http://emberjs.jsbin.com/OxIDiVU/1111/edit

like image 824
Kingpin2k Avatar asked Sep 28 '14 15:09

Kingpin2k


1 Answers

This is a bug with Ember/Ember-data versions. Ember changed its Map implementation in Ember 1.8 beta 3 breaking any version of Ember Data less than 1.0 beta 10.

Here's the github issue: https://github.com/emberjs/data/issues/2323

It's fixed in 1.0.0-beta.11+canary.2997e47034 or above.

like image 61
Kingpin2k Avatar answered Oct 16 '22 15:10

Kingpin2k