1
votes

I have a contact model which contains a id for the contact (id) and a foreign key to a client (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}}

How do I tell the linkTo helper to point to the foreign key?

1

1 Answers

1
votes

The answer lies in the structure of the model. Client needs to be a separate object.

{"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}}