我有一个联系人模型,其中包含联系人的ID(id)和客户端的外键(clientid)。
{"id":131568,
"lastname":"Hansen",
"firstname":"Hans",
"client_id":75264,
"clientname":75264,
}
{{#each contact in controller.contacts}}
{#linkTo "contact.show" contact href="true" }} {{firstname}} {{lastname}}{{/linkTo}}
{#linkTo "client.show" contact href="true" }} {{clientname}} {{/linkTo}}
{{/each}}
如何告诉linkTo助手指向外键?
答案 0 :(得分:1)
答案在于模型的结构。 客户需要是一个单独的对象。
{"id":131568,
"lastname":"Hansen",
"firstname":"Hans",
"client": {
"id":75264,
"clientname":75264,
}
}
{{#each contact in controller.contacts}}
{#linkTo "contact.show" contact href="true" }} {{firstname}} {{lastname}}{{/linkTo}}
{#linkTo "client.show" contact.client href="true" }} {{clientname}} {{/linkTo}}
{{/each}}