Ember-data: populate associations from already loaded data?


In our app we have some models that represent static always loaded data.

Is there a way to populate the associations on a model with data that is already loaded?

For example, we have a model Webfont. Our app loads the list of Webfonts at startup. We have another model Text that belongs_to Webfont. When we retrieve a Text from the backend, is there a way to populate its .webfont attribute from the Webfonts that are already loaded instead of using sideloading/embedding?


This is something that should work. As long as you include the id of the related Webfont in the Text object that you load, ember-data should take care of the relationship for you when it’s loaded into the store.

One thing to check if it’s not working is that all the ids are correct on the Webfont records and on the belongsTo relationship and that you can in fact retrieve the Webfonts from the store by those ids.


I’m not sure why we were having problems with this with ember-data, but it is working using EPF. We switched to EPF to make it easier to implement autosaving.