我想在页面上显示每个操作的收入名称。我想我需要使用belongs_to,但我不知道如何。
我有两张桌子:
IncomeOperation: (id, sum, income_id) 收入: (id, name)
模型/income.js.coffee
EmberMoney.Income = DS.Model.extend
name: DS.attr('string')
description: DS.attr('string')
模型/income_operation.js.coffee
EmberMoney.IncomeOperation = DS.Model.extend
sum: DS.attr('number')
incomeId: DS.belongsTo('EmberMoney.Income') // I think i should be so
路线/addincome_route.js.coffee
EmberMoney.AddincomeRoute = Ember.Route.extend
model: ->
EmberMoney.IncomeOperation.createRecord()
setupController: (controller, model) ->
controller.set('incomes', EmberMoney.Income.find())
controller.set('operations', EmberMoney.IncomeOperation.find())
controller.set('content', model)
模板/addincome.handlebars
{{#each operation in controller.operations}}
<div>
// **Here i want to show income name instead of ID**
{{operation.incomeId}}
{{operation.storageId}}
{{operation.sum}}
{{operation.date}}
</div>
{{/each}}