lundi 23 février 2015

EmberJS no model was found but it's there

I'm writing an ember-cli app. I have the following model:



// app/models/school.js
export default DS.Model.extend({
name: DS.attr('string', { defaultValue: '' })
});


It was generated using an ember generator like all my other models. It has a functioning unit test as well that tests for the default value of it's name attribute. All tests are green until another model belongs to school like this:



// app/models/professor.js
export default DS.Model.extend({
name: DS.attr('string', { defaultValue: '' }),
email: DS.attr('string', { defaultValue: '' }),

courses: DS.hasMany('course'),
posts: DS.hasMany('post'),
school: DS.belongsTo('school')
});


This test is totally green until I add the school attribute. It's even green with 'model:school' defined in the needs array of the moduleForModel helper:



// tests/unit/models/professor-test.js
// this is green w/o belongsTo('school') in the model
moduleForModel('professor', {
// Specify the other units that are required for this test.
needs: ['model:school', 'model:post', 'model:course']
});


The error I'm getting is:



Error: No model was found for 'school'


Here's the models directory



$ ls app/models/
course.js post.js professor.js school.js student.js


Why is it not finding my model?


Aucun commentaire:

Enregistrer un commentaire