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,29 @@
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
save: function() {
let species = this.get('model');
if (species.get('isDirty')) {
species.save().then((species) => {
this.transitionToRoute('species.show', species);
}, (err) => {
this.get('flashMessages').error(err.responseJSON.error);
});
} else {
this.transitionToRoute('species.show', species);
}
},
cancel: function() {
let species = this.get('model');
species.get('errors').clear();
species.rollback();
this.transitionToRoute('species.show', species);
},
},
});