Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember Data not finding model, while it is clearly there

I have as many others upgraded my ember app to the newest version of anything, but after having upgraded, my app is still not working.

I have simplified a lot, and it boils down to my route. My route is like this (as suggested in the transition guide):

App.BoxesRoute = Ember.Route.extend({
  model: function(){
    return this.store.find('box');
  }
});

Extremely simple and nothing should be wrong, right? My model looks like this:

App.Box = DS.Model.extend({
  enabled: DS.attr('boolean'),
  updatedAt: DS.attr('date'),

  boxMeters: DS.hasMany('App.BoxMeter')
});

The App.BoxMeter is very similar, but they key thing is that all of this worked before I upgraded to 1.0.0.

I get a couple of errors thrown in my face. They are:

Assertion failed: No model was found for 'App.Box' ember.js?body=1:394

Error while loading route: TypeError {} ember.js?body=1:394

Uncaught TypeError: Cannot set property 'store' of undefined 

none of which makes any sense for me. I have looked over the routes and models countless times, and this is just .. weird! How should I tackle this?

like image 456
Jan Dragsbaek Avatar asked Sep 03 '13 09:09

Jan Dragsbaek


1 Answers

Try replacing this line:

boxMeters: DS.hasMany('App.BoxMeter')

with:

boxMeters: DS.hasMany('boxMeter')
like image 166
Joachim H. Skeie Avatar answered Sep 21 '22 14:09

Joachim H. Skeie