Ember数据没有找到模型,而它显然在那里 [英] Ember Data not finding model, while it is clearly there
问题描述
我有许多其他人将我的ember应用程序升级到最新版本的任何东西,但升级后,我的应用仍然无法使用。
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')
});
App.BoxMeter非常相似,但关键是所有这些都在我升级之前工作到1.0.0。
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?
推荐答案
尝试替换这一行:
boxMeters: DS.hasMany('App.BoxMeter')
与:
boxMeters: DS.hasMany('boxMeter')
这篇关于Ember数据没有找到模型,而它显然在那里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!