Reputation:
On the ember.js main page (http://www.emberjs.com) about half-way down the page there is a nifty master/detail routing example for a sample mail application.
In true ember documentation style, it is woefully inadequate about how to actually create this yourself and get it working. Even after duplicating the code with the starter kit, big surprise it doesn't work.
How would one go about converting this to ember-cli? The model part of the example seems really wonky in that it doesn't really describe a model, it just does a find by a param passed to it.
I would like some hints on how to convert this code to ember-cli. I have everything converted pretty well, but the model part of the example I am having trouble translating. There is a bigger project in mind that I will use this as a starting point for.
Upvotes: 1
Views: 433
Reputation: 11747
Adding some details for where you are getting stuck would allow for more specific help, but it on the model portion of the conversion. Over on How do I add Projects parent to Ember-CLI TodoMVC? I gave an example of:
App.Todo = DS.Model.extend({
name: DS.attr('string'),
//project : DS.belongsTo('project')
});
App.Todo.FIXTURES = [{
id: 1,
name: 'shop',
project: 1
}, {
id: 2,
name: 'sell things',
project: 2
}, {
id: 4,
name: 'dance',
project: 3
}];
So if I were adding these to Ember-cli manually (not with the generator) I could do it two ways, but for both the code in the file would be:
import DS from "ember-data";
var Todo = DS.Model.extend({
name: DS.attr('string'),
//project : DS.belongsTo('project')
});
Todo.reopenClass({
FIXTURES: [{
id: 1,
name: 'shop',
project: 1
}, {
id: 2,
name: 'sell things',
project: 2
}, {
id: 4,
name: 'dance',
project: 3
}]
});
export
default Todo;
Hope that helps un-murky the waters a bit.
Upvotes: 1