Reputation: 4033
This has been asked multiple times, however nothing has worked for me.
App.CatalogAddRoute = Ember.Route.extend({
// other stuff ...
actions: {
save: function() {
this.get('store').createRecord('category', {
category_id: 4,
category_name_fr_sh: "wat"
//... other properties
});
this.get('store').commit();
this.get('target.router').transitionTo('catalog.index');
}
}
});
I can see in my Ember toolbar that my createRecord did work. One more Category has been add to my controller. But the commit() always throws me the same error:
Object [object Object] has no method 'commit'
Anyone has a hint here at what could be wrong ?
Upvotes: 2
Views: 1074
Reputation: 47367
You call save on the model instead of commit on the store, it's possible you're looking at old documentation, or documentation for a different version of ED than that of which you're using, see https://github.com/emberjs/data/blob/master/TRANSITION.md for the changes made when they went to 1.0 beta releases
actions: {
save: function() {
var record = this.get('store').createRecord('category', {
category_id: 4,
category_name_fr_sh: "wat"
//... other properties
});
record.save();
this.get('target.router').transitionTo('catalog.index');
}
}
Upvotes: 3