Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrapping data models in Ember?

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?

like image 421
bcardarella Avatar asked Mar 19 '13 15:03

bcardarella


2 Answers

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

like image 95
calumbrodie Avatar answered Oct 15 '22 07:10

calumbrodie


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

like image 2
Andrew Gertig Avatar answered Oct 15 '22 06:10

Andrew Gertig