Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
App.CreateUserRoute = Em.Route.extend({
transaction: null,
model: function() {
this.transaction = App.store.transaction();
return this.transaction.createRecord(App.User);
},
events: {
submit: function(user) {
var errors = {};
if (Em.isEmpty(user.get('name')))
errors.name = "Name is required";
if (!$.isEmptyObject(errors)) {
user.set('errors', errors);
user.set('isValid', false);
return;
}
var self = this;
user.one('didCreate', function() {
this.transitionTo('user', user);
});
this.transaction.commit();
}
},
exit: function() {
this.transaction.rollback();
}
});
@stefek99

This comment has been minimized.

Copy link

commented Jun 19, 2015

For anyone coming from StackOverflow / other sources... Transactions are no more.

See: https://github.com/emberjs/data/blob/master/TRANSITION.md#transaction-is-gone-save-individual-records

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.