protected route

This commit is contained in:
Matthew Dillon 2015-07-10 09:29:12 -08:00
parent 72c957f8dc
commit eb1a8bb6e3
41 changed files with 56 additions and 43 deletions

View file

@ -0,0 +1,30 @@
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
save: function() {
let strain = this.get('strain');
if (strain.get('isDirty')) {
strain.save().then((strain) => {
this.transitionToRoute('strains.show', strain);
}, (err) => {
this.get('flashMessages').error(err.responseJSON.error);
});
} else {
strain.deleteRecord();
this.transitionToRoute('strains.show', strain);
}
},
cancel: function() {
let strain = this.get('strain');
strain.get('errors').clear();
strain.rollback();
this.transitionToRoute('strains.show', strain);
},
},
});