5
votes

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?

2

2 Answers

6
votes

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

2
votes

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