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,10 +6,8 @@
 } = Ember;
 
 export default Mixin.create({
-  primaryModel: 'model',
   resetController() {
-    let primaryModel = get(this, 'primaryModel');
-    let model = get(this, `controller.${primaryModel}`);
+    let model = get(this, 'controller.model');
 
     if (!get(model, 'isDeleted')) {
       model.rollbackAttributes();
@@ -17,8 +15,7 @@
   },
   actions: {
     willTransition(transition) {
-      let primaryModel = get(this, 'primaryModel');
-      let model = get(this, `controller.${primaryModel}`);
+      let model = get(this, 'controller.model');
 
       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`.