So while writing an Ember.js app, I couldn’t get the most basic ember-data records to work. Using the latest git builds of Ember.js and ember-data, I ran this code in firebug: (Using what I learned from the guide to ember-data on github)
App.store = DS.Store.create({
revision: 8,
adapter: DS.RESTAdapter.create({bulkCommit: false, namespace: "api"})
});
App.Test = DS.Model.extend({
test: DS.attr('string')
});
App.store.load(App.Test, 1, {test: "abc"});
App.store.findById(App.Test, 1);
Edit: mspisars’ answer made me realize that findById() is not the function to use (Although it does have the same result). That’s a function for internal ember-data use.
The last line returns an App.Test object with its test property set to “undefined”. I got the same results using createRecord to create the record (admittedly I don’t remember the difference).
From what I can see this is not a duplicate of this question, although the symptoms are almost the same.
Thanks for any help.
I was accessing the stored data in the wrong way. After loading the data, I was trying to get the data like this:
That returns undefined.
I should have done this: