Skip to content

Instantly share code, notes, and snippets.

@cmosguy
Forked from ultimatemonty/ember-crud-pattern.js
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmosguy/b244b8daace520494cbc to your computer and use it in GitHub Desktop.
Save cmosguy/b244b8daace520494cbc to your computer and use it in GitHub Desktop.
App.PostsController = Em.ArrayController.extend({
actions: {
create: function () {
// some validation logic here
return this.send('createPost');
},
save: function (model) {
// some validation logic here
return this.send('savePost');
},
delete: function (model) {
// some validation logic here
return this.send('deletePost');
}
}
});
App.PostsRoute = Em.Route.extend({
actions: {
createPost: function () {
var post = store.createRecord( /* stuff here */ );
post.save().then(function (result) {
// some sucecss handling
}, function(error) {
// some error handling
});
},
savePost: function(model) {
model.save().then(function (result) {
// some sucecss handling
}, function(error) {
// some error handling
});
},
deletePost: function(model) {
model.deleteRecord();
model.save().then(function (result) {
// some sucecss handling
}, function(error) {
// some error handling
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment