我正在尝试与Tom Dale's youtube video一起建立一个简单的博客。我从GH克隆了ember-data master并构建了它,但是我遇到了两个错误:
Uncaught TypeError: Object [object Object] has no method 'readOnly'
来自ember-data和
的内容Uncaught TypeError: Object [object Object] has no method 'attr'
是我在模型中第一次使用DS.attr。我的代码可以在GitHub以及
上找到/* Ember and Ember-Data are shimmed in as deps */
define([], function () {
'use strict';
var App = Ember.Application.create();
App.Store = DS.Store.extend({
revision: 12,
adapter: 'DS.FixtureAdapter'
});
App.Router.map(function () {
this.resource('about');
});
App.Post = DS.Model.extend({
title: DS.attr('string'),
author: DS.attr('string'),
intro: DS.attr('string'),
extended: DS.attr('string'),
publishedAt: DS.attr('date')
});
App.Post.FIXTURES = [{
id: 1,
title: "Rails is Omakase",
author: "d2h",
publishedAt: new Date('12-27-2012'),
intro: "There are lots of a la carte software",
extended: "I want this for my ORM"
}];
return App;
});
答案 0 :(得分:2)
.readonly()
是在最新版本的数据库内部使用的Ember方法,该方法仅在Ember.JS RC1和RC2之间添加。如果要使用主Ember-Data,则需要使用Ember主。