mercredi 29 avril 2015

Cannot read property 'match' of undefined at Ember.DefaultResolver.extend.podBasedComponentsInSubdir

I'm getting a really opaque error message (opaque in the sense I have no point of reference for my own source) from console, I'm not entirely sure where to look, I feel it's likely an error in library code but before posting this on github I'll just double check it's not my own fault.

The Problem

The Problem is simple, I'm calling this.store.find('player'), in hopes to get a list of all players, and then display them in some kind of list, but I'm not even getting past the loading part. The data is pulled from the server and looks properly formatted, but something seems to be failing after the route.model method call. And the error message seems to be somewhere in the ember.js library code with nothing pointing back to my own code.

Server Response

The content type is of course application/json, and note the id property is actually _id.

[
  {
    "_id":"55405a5102b4ed623c225e87",
    "alias":"mikeTest",
    "__v":0,
    "scans":[],
    "createdAt":"2015-04-29T04:13:05.223Z"
  }
]

Error message

Note there is part of the stack trace pointing to my source, only Ember source. Which has made this a pain to debug.

Error while processing route: leader Cannot read property 'match' of undefined TypeError: Cannot read property 'match' of undefined
    at Ember.DefaultResolver.extend.podBasedComponentsInSubdir (http://localhost:4200/assets/vendor.js:60138:76)
    at http://localhost:4200/assets/vendor.js:60190:34
    at Array.exports.default.mixin.Mixin.create.find (http://localhost:4200/assets/vendor.js:39572:30)
    at Ember.DefaultResolver.extend.findModuleName (http://localhost:4200/assets/vendor.js:60188:44)
    at resolveOther (http://localhost:4200/assets/vendor.js:60051:37)
    at superWrapper (http://localhost:4200/assets/vendor.js:28141:20)
    at exports.default.EmberObject.default.extend.resolve (http://localhost:4200/assets/vendor.js:15454:35)
    at Object.resolve [as resolver] (http://localhost:4200/assets/vendor.js:15217:23)
    at resolve (http://localhost:4200/assets/vendor.js:12792:29)
    at Object.Registry.resolve (http://localhost:4200/assets/vendor.js:12336:21)

Source

This ember app is very young, so there is very little source at the moment, but this is all the relevant source at the moment.

Routes

import Ember from 'ember';
import config from './config/environment';

var Router = Ember.Router.extend({
  location: config.locationType
});

export default Router.map(function() {
  this.resource('leader');
  this.resource('profile');
  this.route('loading');
});

Leader route

Leader has a template and a controller, but they are basically empty right now.

import Ember from 'ember';

export default Ember.Route.extend({
  model: function () {
    return Ember.RSVP.hash({
      players: this.get('store').find('player')
    });
  },
});

Player Model

import DS from 'ember-data';

export default DS.Model.extend({
  alias: DS.attr('string'),
  createdAt: DS.attr('date'),
  scans: DS.hasMany('scan'),
});

Application Adapter

import DS from 'ember-data';


export default DS.RESTAdapter.extend({
  namespace: ''
});

Application Serialiser

import DS from 'ember-data';

export default DS.RESTSerializer.extend({
  primaryKey: function (type) {
    return '_id';
  },

  serializeId: function(id) {
    return id.toString();
  }
});

Package.json

{
  "name": "hunter",
  "version": "0.0.0",
  "description": "Small description for hunter goes here",
  "private": true,
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "scripts": {
    "start": "ember server",
    "build": "ember build",
    "test": "ember test"
  },
  "repository": "",
  "engines": {
    "node": ">= 0.10.0"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "broccoli-asset-rev": "^2.0.2",
    "ember-cli": "0.2.3",
    "ember-cli-app-version": "0.3.3",
    "ember-cli-babel": "^5.0.0",
    "ember-cli-content-security-policy": "0.4.0",
    "ember-cli-dependency-checker": "0.0.8",
    "ember-cli-htmlbars": "0.7.4",
    "ember-cli-ic-ajax": "0.1.1",
    "ember-cli-inject-live-reload": "^1.3.0",
    "ember-cli-jshint": "0.0.0",
    "ember-cli-qunit": "0.3.10",
    "ember-cli-sass": "4.0.0-beta.6",
    "ember-cli-uglify": "1.0.1",
    "ember-data": "1.0.0-beta.16.1",
    "ember-export-application-global": "^1.0.2",
    "semantic-ui-ember": "0.0.1-rc.8"
  }
}

Things I've tried

  • removing properties from the model, in the event the relationships seemed to be the problem (nothing changed)
  • tried setting up a serialiser and adapter for the application (included above), nothing changed.
    • the serialiser in the event that the id field in the response is actually _id.
  • tried updating ember data, nothing changed.



Aucun commentaire:

Enregistrer un commentaire