I use this guide to create a custom adapter for Ember Data: http://emberjs.com/api/data/classes/DS.Adapter.html
In my app.js I have the following:
App.store = DS.Store.create({
adapter: 'MyAdapter'
});
I created the adapter:
App.MyAdapter = DS.Adapter.extend({
createRecord: function(store, type, record) {
console.log('create');
},
deleteRecord: function(store, type, record) {
console.log('delete');
},
find: function(store, type, id) {
console.log('find');
},
findAll: function(store, type, sinceToken) {
console.log('findAll');
},
findQuery: function(store, type, query) {
console.log('findQuery');
},
updateRecord: function(store, type, record) {
console.log('updateRecord');
}
});
And I created a model:
App.Post = DS.Model.extend({
title: DS.attr,
body: DS.attr,
author: DS.attr
});
Then in a route I have:
this.store.createRecord('post', {
title: 'Rails is Omakase',
body: 'Lorem ipsum',
author: 'asd'
});
var post = this.store.find('post');
console.log(post);
Unfortunately, this does not work, as there are several errors in console output:
Assertion failed: Unable to find fixtures for model type App.Post
Assertion failed: The response from a findAll must be an Array, not null
TypeError: Cannot read property 'map' of null
.
So my first guess is, that it can't find my custom adapter, as there is also no logging if the function gets called (console.log('find')
...). Is the documentation even up to date? Is the string MyAdapter
correct? Shouldn't it be like this:
App.store = DS.Store.create({
adapter: 'App.MyAdapter'
});
Nothing works. What have I done wrong?
One further question: Is there a good ember data adapter for web sockets?