import Ember from 'ember';

const {
  get,
  Mixin
} = Ember;

export default Mixin.create({
  primaryModel: 'model',
  resetController() {
    let primaryModel = get(this, 'primaryModel');
    let model = get(this, `controller.${primaryModel}`);

    if (!get(model, 'isDeleted')) {
      model.rollbackAttributes();
    }
  },
  actions: {
    willTransition(transition) {
      let primaryModel = get(this, 'primaryModel');
      let model = get(this, `controller.${primaryModel}`);

      if (get(model, 'hasDirtyAttributes') && !this.willTransitionConfirm(transition)) {
        transition.abort();
      }
    }
  },
  willTransitionConfirm() {
    return true;
  }
});

import Ember from 'ember';

const {
  get,
  Mixin
} = Ember;

export default Mixin.create({
  resetController() {
    let model = get(this, 'controller.model');

    if (!get(model, 'isDeleted')) {
      model.rollbackAttributes();
    }
  },
  actions: {
    willTransition(transition) {
      let model = get(this, 'controller.model');

      if (get(model, 'hasDirtyAttributes') && !this.willTransitionConfirm(transition)) {
        transition.abort();
      }
    }
  },
  willTransitionConfirm() {
    return true;
  }
});

--- 
+++ 
@@ -6,8 +6,10 @@
 } = Ember;
 
 export default Mixin.create({
+  primaryModel: 'model',
   resetController() {
-    let model = get(this, 'controller.model');
+    let primaryModel = get(this, 'primaryModel');
+    let model = get(this, `controller.${primaryModel}`);
 
     if (!get(model, 'isDeleted')) {
       model.rollbackAttributes();
@@ -15,7 +17,8 @@
   },
   actions: {
     willTransition(transition) {
-      let model = get(this, 'controller.model');
+      let primaryModel = get(this, 'primaryModel');
+      let model = get(this, `controller.${primaryModel}`);
 
       if (get(model, 'hasDirtyAttributes') && !this.willTransitionConfirm(transition)) {
         transition.abort();
feat: Add a primary model attribute

`primaryModel` defaults to `'model'` but can be changed in cases where the `model` hook must return an array or hash of promises and the user wants to be explicit about the model in the template e.g. `user` vs `model`.