I'm doing my damnedest to find and/or cobble together a working jsfiddle of a hasMany/belongsTo relationship in the latest version of ember.js and ember-data that utilizes the RESTAdapter. So far I have found a pre.4 baseline fiddle by @zgramana that puts the new router through some exploration and a @sly7-7 fiddle that utilizes the necessary DS relationship, but bypasses the router for the sake of brevity.
My fumbling WIP attempt to cobble these together into a cohesive example can be found here: http://jsfiddle.net/W2dE4/5/ . I'm obviously a newcomer to ember.js and this fiddle is riddled with errors, so please excuse the lack of skills.
App.Store = DS.Store.extend({
revision: 11,
adapter: DS.RESTAdapter.create({})
});
App.Post = DS.Model.extend({
title: DS.attr('string'),
post: DS.attr('string'),
comments: DS.hasMany('App.Comment')
});
App.Comment = DS.Model.extend({
post: DS.belongsTo('App.Post'),
description: DS.attr('string')
});
store = App.__container__.lookup('store:');
store.load(App.Post, {
id: 1,
title: 'Post 1 Title',
post: 'Body of post 1',
comments:[1,2]
},
{
id: 2,
title: 'Post 2 Title',
post: 'text of post 2',
comments:[3,4]
},
{
id: 3,
title: 'Post 3 title',
post: 'text of post3',
comments:[5,6]
}
);
store.load(App.Comment, {id: 1, description: "Great post!"},
App.Comment, {id: 2, description: "Post sucks."},
App.Comment, {id: 3, description: "Nice style"},
App.Comment, {id: 4, description: "Horrible writing"},
App.Comment, {id: 5, description: "Ember.js FTW"},
App.Comment, {id: 6, description: "Get up get out n' get something"}
);
If anyone can point me in the right direction to get this fiddle working, or link to a working example of pre.4 with the RESTAdapter and a hasMany relationship, I would be forever indebted to your generosity.
Thank you kindly!