Frequently this data will not load, even though there are key values in the relationship array, and the table will be blank. Reloading the page always results in a correct load.
This is the only place in the app, currently, where I am nesting relationship data.
Thank you. I thought that was how side-loaded data was supposed to work. The template renders and then the data fills in as the relationships are retrieved and loaded.
It is. When you say side-loaded though do you mean that the relationship data is in the same API payload? Or do you mean lazy-loaded via additional requests? Are the relationships defined as async (default) or sync?
import AccountModel from "./account";
import {attr, belongsTo} from '@ember-data/model';
import {computed} from '@ember/object';
export default class BorrowerAccountModel extends AccountModel {
@attr borrowerAccountId;
@belongsTo("customer") borrowerId;
@attr customerId;
@attr borrowerTypeId;
...
@attr lienPosition;
@attr collectibleAccountNumber;
}
[Note: there is no semantic difference between a borrower and a customer. There is a gradual refactor going on that is replacing borrower with customer.]
Hmmmm nothing is jumping out. Are the requests for the related records made correctly? The way I typically debug this sort of thing is:
check that the requests for the related data are made properly
inspect the “primary” record and look at its relationships (in ember inspector/console)
looking at the contents of the store to see if the related records are there (assuming the requests look fine in bullet 1) and look right
you could also try throwing {{log relatedBorrower}} and {{log relatedAccount}} in the first and second “each” loop respectively to see if they’re being “executed”. You could also throw some debug logs in for the @customer model and the relationship statuses (which would tell you if the relationships are pending or have been loaded, and if loaded and they don’t have a length then you know where to look next)
this part is suspicious to me… do you have any idea what circumstances lead to the data not being loaded/shown? if reloading always works, is there some situation where it always breaks? That might be a good place to start investigating as well.
Thanks, much. I’ll try the logging. So far, no, I have not found a way to make it fail. The logging should help. (I actually did not know about {{log …}}.) That will be a great help.
To close this out, I never did get the nested side-loaded data to work 100% of the time. It worked about 90% of the time in production and 99% of the time in development.
Instead, I’m loading the data directly in the route now. It’s cleaner and more transparent, anyway.