Guys, I am really sorry if this question is too simple/stupid. I am new to ember, so I tried to find similar questions and also tried to understand the mechanism from the docs => no result.
What do I have?
2 models with one-to-many relationship
Mailbox:
inboxLetters: DS.hasMany('letter', { inverse: 'receiver' }),
outboxLetters: DS.hasMany('letter', { inverse: 'sender' })
Email:
receiver: DS.belongsTo('mail', { async: true }),
sender: DS.belongsTo('mail', { async: true })
What do I do?
return this.store.find('letter', {
receiver: params.mail_id,
status: 'sent',
sender: true
});
This works pretty fine. I got a lot of letters, each of them I can use and get sender.id.
return this.store.find('letter', 1, { receiver: true, sender: true });
And here is the main problem. I’ve got an error: Error while processing route: letter Assertion Failed: You cannot add a ‘undefined’ record to the ‘letter.sender’. You can only add a ‘mail’ record to this relationship. That’s not clear to me, why I can get all objects without any problems and cannot get only one?
Problem was in http-mock that I used, thanks to nobody, u can delete this post now. Check your json guys and be happy)