我試圖用餘燼數據定義我的模型,但由於某種原因,我添加了一些 hasMany
或belongsTo
關係後,出現'Uncaught TypeError:不能調用未定義的方法'modelFor'Ember數據:未捕獲TypeError:無法調用未定義的方法'modelFor'
我在做什麼錯了?
App.User = DS.Model.extend({
username: DS.attr('string'),
facebook_id: DS.attr('string'),
staff: DS.attr('boolean', {defaultValue: false}),
createdAt: DS.attr('date'),
posts: DS.hasMany('post', {async: true}),
comments: DS.hasMany('comment', {async: true)
})
App.Post = DS.Model.extend({
title: DS.attr('string'),
image: DS.attr('string'),
track: DS.attr('string'),
createdAt: DS.attr('date'),
user: DS.belongsTo('user'),
comments: DS.hasMany('comment', {async: true})
})
App.Comment = DS.Model.extend({
user: DS.belongsTo('user'),
post: DS.belongsTo('post'),
track: DS.attr('string'),
createdAt: DS.attr('date')
})