Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


bug: app init faild when applicationControl have function name endwiths "Controller" #352

any35 opened this Issue · 7 comments

3 participants

any35 Bradley Priest Peter Wagenet

i have a ApplicationController, and a function in it

var App = Em.Application.create(
  registerController : function (name, controller) {
          //something other code.....

when the app initialize, it throw an exception "Cannot call method 'set' of undefined.
i debug throw and found the code in ember-data-latest.js like this

    name: "giveStoreToControllers",

    injection: function(app, stateManager, property) {
      if (property.match(/Controller$/)) {
        var controllerName = property.charAt(0).toLowerCase() + property.substr(1);
        var store = stateManager.get('store');
        var controller = stateManager.get(controllerName);

        controller.set('store', store);

it injection anything that endwiths'Controller", so does 'registerController '.
so stateManager.get(controllerName) return undefined, and the exception happend.

but inface, function 'registerController ' may not intend to be included in this feature.

it's there any thing workaround?

Bradley Priest

This is a bit of an edge case that I doubt will be changed.
At this point in time I suggest you either just rename your function to not end in Controller or namespace the function inside an object that isn't the direct Application.
This is definitely something that needs to be documented somewhere though, thanks.

Peter Wagenet

@bradleypriest we could try to detect that the property is an Ember.Controller but maybe we want to support straight Ember.Objects as controllers.

Bradley Priest

@wagenet I like that idea, if people want to use plain Ember.Objects as controllers, they could always just inherit from Ember.Controller instead, it currently doesn't add anything special to an object. Do you know if there is anything in the pipeline about adding significant functionality to the vanilla Ember.Controller class?

Bradley Priest

Actually maybe it'd be better to add a flag like instantiateOnInitialize to the base Ember.Controller class for complete flexibility.

Peter Wagenet

@bradleypriest That seems like probably more complexity than we need. I think we should check for Ember.ControllerMixin or even just Ember.Object. Interested in sending a PR?

Bradley Priest

@wagenet I've pushed a fix for this particular issue, namely checking for a capitalized controller name as per the main ember repo. I'll push another PR for checking for Ember.Object soon, that one requires changes to both ember.js and ember-data.

Peter Wagenet


Peter Wagenet wagenet closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.