kimroen / ember-cli-coffeescript

Adds precompilation of CoffeeScript files and all the basic generation types to the ember generate command.
MIT License
72 stars 49 forks source link

When a route doesn't have a model property defined and the route is hit, the route is unrecognized #142

Closed ckl1989 closed 7 years ago

ckl1989 commented 7 years ago

This seems to only happen to coffeescript routes as I tried it with es6 on embertwiddle and didn't run into any problems.

I have the following code:

import Ember from 'ember'
CompaniesRoute = Ember.Route.extend
  # model: -> []

export default CompaniesRoute

which translates to:

define('relationship/routes/companies', ['exports', 'ember'], function (exports, _ember) {
  var CompaniesRoute;

  CompaniesRoute = _ember['default'].Route.extend;

  exports['default'] = CompaniesRoute;
});

When I access this route through URL, I get the following error message in console:

Error message: Assertion Failed: Expected route:companies to resolve to an Ember.Route but instead it was function () {
      var Class = makeCtor();
      var proto;
      Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin);
      Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin);

      Class.ClassMixin.ownerConstructor = Class;
      Class.PrototypeMixin.ownerConstructor = Class;

      reopen.apply(Class.PrototypeMixin, arguments);

      Class.superclass = this;
      Class.__super__ = this.prototype;

      proto = Class.prototype = Object.create(this.prototype);
      proto.constructor = Class;
      _emberUtils.generateGuid(proto);
      _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype

      Class.ClassMixin.apply(Class);
      return Class;
    }.

It looks like it can't find that route without the model property because when I uncomment the model property above, it works. The error that is resulted is kind of confusing, especially to beginners since by all account the route "is" defined and there.

ckl1989 commented 7 years ago

The issue was in my source code. I was using Ember.Route.extend vs Ember.Route.extend().

Closing issue