Reputation:
I am a bit of a newbie to Ember.js and I am having an issue when trying to use the model function within a route.
I have been following the docs on the ember website and so far have the following.
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();
}
});
This gives me the following in chrome's console
Uncaught TypeError: Cannot read property 'find' of undefined
Thanks
EDIT: I am using ember-1.0.0-rc.3 and I have the adapter set up.
FIX: Make sure your not making school boy errors like me and check your ember data is up to date
Upvotes: 1
Views: 1988
Reputation: 1847
What revision of ember data are you using? Is your adapter setup properly? i.e.
App.Store = DS.Store.extend({
revision: 12,
adapter: 'DS.FixtureAdapter'
});
Edit:
Your fixture data needs to have an ID attribute
App.Latest.FIXTURES = [{
"id" : 1,
"title" : "test Title",
"volume": "test volume",
"issue" : "test issue",
}];
http://jsbin.com/odijiq/3/edit working example
Upvotes: 3