I would like to bootstrap an application with data without having to do an additional request. Assuming I have a simple user model with the following json:
{"user":{"id":1,"email":"[email protected]"}}
This json is being dumped by a Rails app. How best should I bootstrap my User
model in Ember?
Use
App.Store.load(App.YourModel, yourdata);
See this question:
Ember-data bootstrapping model objects
edit: not sure if you can load multiple objects at once - you may have to loop your collection. Suggest using something like underscore.js
If your goal is to bootstrap a Model from JSON then you should use the push() method as detailed here: http://emberjs.com/guides/models/pushing-records-into-the-store/#toc_pushing-records
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With