アプリの開発時に、FixtureAdapter を使用してデータをローカルに読み込みます。
これらはフィクスチャデータを含む私のページモデルです:
App.Page = DS.Model.extend({
name : DS.attr('string'),
parent : DS.belongsTo('App.Page'),
subpages : DS.hasMany('App.Page')
});
App.Page.FIXTURES = [{
id: 1,
name: 'Home',
subpages: [ 2, 3, 4 ]
},{
id: 2,
name: 'About',
parent: 1
},{
id: 3,
name: 'Contact',
parent: 1
},{
id: 4,
name: 'Search',
parent: 1
},{
id: 5,
name: 'Blog',
parent: 2
}];
これは、フィクスチャ内のすべての Page オブジェクトを返すコードです
App.PagesRoute = Ember.Route.extend({
model: function() {
return App.Page.find();
}
});
これは私の App.store です:
App.store = DS.Store.create({
revision : 11,
adapter: DS.FixtureAdapter
});
これはうまく機能しますが、ルート ページを返すにはどうすればよいですか?
変更return App.Page.find()
するApp.Page.findQuery(App.Page,{ id: 1 })
と、次のエラーが表示
されます。Uncaught Adapter is either null or does not implement 'findQuery' method
- アップデート -
変更return App.Page.find()
するApp.Page.find({ name: 'Home' })
と、次のエラーが表示
されます。Uncaught TypeError: Cannot call method '_create' of undefined
その時点でデータがロードされていないためだと思います。しかし、私はそれをEmberが処理してくれると思っていました。