0

I'm new to ember and I'm pulling back some JSON via DS.RESTAdapter() which looks like:

{"apis":[{"id":"0",name:"test",methods:[{"id":"0","name":"test"},{"id:"1","name":"test2"}]}]}

My models:

App.Api = DS.Model.extend({
    name: DS.attr('string'),
    methods: DS.hasMany('App.ApiMethod')
});

App.ApiMethod = DS.Model.extend({
    api: DS.belongsTo('App.Api'),
    name: DS.attr('string')
});

I can read the Api model properties fine but if I try and loop through the methods property, it's empty. I've also tried passing in { embedded: true } as an option in the DS.hasMany() call.

Any ideas?

1
  • I eventually came to the conclusion that Ember is shit and the docs are poor. I moved to Angular and love it.
    – eth0
    Jun 12, 2013 at 8:37

1 Answer 1

0

you aren't using the default rest format for nested models -> http://emberjs.com/guides/models/the-rest-adapter/#toc_sideloaded-relationships

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.