2015-02-24 80 views
4

我在寫一個ember-cli應用程序。我有以下型號:EmberJS找不到模型,但它在那裏

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

而且,利用餘燼發生器如同我所有的其他車型產生。它有一個功能單元測試,並測試它的name屬性的默認值。所有的測試都是綠色的,直到另一種模式屬於學校是這樣的:

// 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') 
}); 

這個測試是完全綠色的,直到我加入了學校的屬性。它甚至綠色與needs陣列moduleForModel幫手定義'model:school'

// 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'] 
}); 

我得到的錯誤是:

Error: No model was found for 'school' 

這裏的車型目錄

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

爲什麼它沒有找到我的模型?

+0

你有沒有想出解決辦法? – bschaeffer 2016-02-02 14:18:40

+0

沒有。我停止使用Ember。真的不太喜歡它。 – Hugo 2016-02-02 20:46:06

回答

-2

您需要進口學校模型測試:

import '[appName]/models/school'; 
+0

但是我沒有必要那樣做任何其他測試。這是一個呃應用程序。 – Hugo 2015-02-24 13:58:06

相關問題