Ember.js模型函数,无法读取未定义的属性'find'

时间:2013-04-22 16:29:12

标签: javascript ember.js

我是Ember.js的新手,我在尝试在路线中使用模型功能时遇到了问题。

我一直在关注ember网站上的文档,到目前为止还有以下内容。

App.Latest = DS.Model.extend({
title: DS.attr('string'),
volume: DS.attr('string'),
issue: DS.attr('string')
});

App.Latest.FIXTURES = [{
"title": "test Title",
"volume": "test volume",
"issue": "test issue",
}];

App.LatestRoute = Ember.Route.extend({
    model: function() {
        return App.Latest.find();
  }
});

这在chrome的控制台中提供了以下内容

未捕获的TypeError:无法读取未定义的属性“find”

由于

编辑:我正在使用ember-1.0.0-rc.3并且我已经设置了适配器。

FIX:确保你没有像我这样的男生错误并检查你的余烬数据是最新的

1 个答案:

答案 0 :(得分:3)

您使用的是什么版本的余烬数据?您的适配器设置正确吗? 即。

App.Store = DS.Store.extend({
  revision: 12,
  adapter: 'DS.FixtureAdapter'
});

编辑:

您的灯具数据需要具有ID属性

App.Latest.FIXTURES = [{
  "id"    : 1,
  "title" : "test Title",
  "volume": "test volume",
  "issue" : "test issue",
}];

http://jsbin.com/odijiq/3/edit工作示例