lundi 29 décembre 2014

Sideloading with Ember ActiveModelAdapter and Rails

I have two models:



user: [
firstName: DS.attr('string'),
lastName: DS.attr('string'),
animals: DS.hasMany('animal', { async: true })
]

animal: [
name: DS.attr('string'),
user: DS.belongsTo('user', { async: true })
]


When I see animals route all works fine, the JSON that rails return is like:



{"animals":[{"id":1,"name":"Wiskey","user_id":3}


and Ember call a GET for the user/3.


When I try to find all users what I have is this json:



{"users":[{"id":3,"firstName":"Bob","lastName":"Marley","animal_ids":[4,8,14]}


but no GET was call for the animals 4, 8 and 14. What is the problem? The adapter that I use is ActiveModelAdapter.


Thanks!





Aucun commentaire:

Enregistrer un commentaire