I have been trying to get Ember fixtures data working on a test app I am developing that's based on the ember-rails gem. The data model seems to be loading when I use the Chrome Ember inspector tool but it doesn't load the actual data.
I have the following setup.
router.js
App.Router.map(function() {
this.resource('projects'), { path: '/' };
});
store.js
App.ApplicationAdapter = DS.FixtureAdapter
models/project.js
App.Project = DS.Model.extend({
name: DS.attr('string')
});
App.Project.FIXTURES = [
{ id: 1,
name: 'Test data 1'
},
{ id: 2,
name: 'Test data 2'
}
];
routes/projectsRoute.js
App.ProjectRoute = Ember.Route.extend({
model: function() {
return this.store.find('project');
}
});
As i mentioned this is built on top of rails using the ember-rails gem.
Any help would be much appreciated :)
Instead of adding FIXTURES
as a key, it looks like you have to reopen the Model:
App.Project.reopenClass({
FIXTURES: [
{ id: 1,
name: 'Test data 1'
},
{ id: 2,
name: 'Test data 2'
}
]
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.