Ember データ用に独自のアダプターを展開しています。簡単に言うと、 App.store.updateRecord(App.Model, id ) を呼び出すと、次のエラーが発生します。
Uncaught TypeError: Object <DS.Store:ember195> has no method 'updateRecord'
updateRecord 関数が実装されていても。
以下のサンプルコード(わかりやすくするために、すべての関数が想定されていることを実行する代わりに、すべての関数にパラメーターをコンソールに記録させました)
// declare application namespace
App = Ember.Application.create();
// instantiate store
App.store = DS.Store.create({
revision: 2,
adapter: DS.LocalStorageAdapter.create(),
});
// implement adapter
DS.LocalStorageAdapter = DS.Adapter.extend({
createRecord: function(store, type, model) {
console.log('createRecord: ', type, model);
},
updateRecord: function(store, type, model) {
console.log('updateRecord: ', type, model);
},
find: function(store, type, id) {
console.log('find: ', type, id);
},
localStorage: {
set: function( ModelTyp, value ){},
get: function( ModelType ){},
}
});
// create model
App.StyleData = DS.Model.extend({
css_name: DS.attr('string', {key: 'css_name'}),
storageID: DS.attr('number', {defaultValue: 0, key: 'storageID'}),
});
// ==========================================================================
// Test Application
// ==========================================================================
App.store.createRecord(App.StyleData, { css_name: 'name' });
App.store.commit()
//console: createRecord: App.StyleData, model
App.store.find(App.StyleData, 0)
//console: find: App.StyleData, 0
App.store.updateRecord(App.StyleData, { css_name: 'new name' });
//console: Uncaught TypeError: Object <DS.Store:ember195> has no method 'updateRecord'
ボンネットの下で何が起こっているのか理解できないので、ここではほとんど私の知恵の終わりです。