var set = Ember.set;

Ember.onLoad('Ember.Application', function(Application) {
  Application.registerInjection({
    name: "store",
    before: "controllers",

    injection: function(app, stateManager, property) {
      if (!stateManager) { return; }
      if (property === 'Store') {
        set(stateManager, 'store', app[property].create());
      }
    }
  });

  Application.registerInjection({
    name: "giveStoreToControllers",

    injection: function(app, stateManager, property) {
      if (!stateManager) { return; }
      if (/^[A-Z].*Controller$/.test(property)) {
        var controllerName = property.charAt(0).toLowerCase() + property.substr(1);
        var store = stateManager.get('store');
        var controller = stateManager.get(controllerName);

        controller.set('store', store);
      }
    }
  });
});

var set = Ember.set;

Ember.onLoad('Ember.Application', function(Application) {
  Application.registerInjection({
    name: "store",
    before: "controllers",

    injection: function(app, stateManager, property) {
      if (property === 'Store') {
        set(stateManager, 'store', app[property].create());
      }
    }
  });

  Application.registerInjection({
    name: "giveStoreToControllers",

    injection: function(app, stateManager, property) {
      if (/^[A-Z].*Controller$/.test(property)) {
        var controllerName = property.charAt(0).toLowerCase() + property.substr(1);
        var store = stateManager.get('store');
        var controller = stateManager.get(controllerName);

        controller.set('store', store);
      }
    }
  });
});

--- 
+++ 
@@ -6,6 +6,7 @@
     before: "controllers",
 
     injection: function(app, stateManager, property) {
+      if (!stateManager) { return; }
       if (property === 'Store') {
         set(stateManager, 'store', app[property].create());
       }
@@ -16,6 +17,7 @@
     name: "giveStoreToControllers",
 
     injection: function(app, stateManager, property) {
+      if (!stateManager) { return; }
       if (/^[A-Z].*Controller$/.test(property)) {
         var controllerName = property.charAt(0).toLowerCase() + property.substr(1);
         var store = stateManager.get('store');
Support apps without a router
