still trying to build an invoicing app using ember-model and hasMany relationships using the FixtureAdapter for now. When i try to create a new invoice record, i get a new invoice without error, but without an ID at all (it is undefined), am i supposed to handle the id creation server-side ? :/ and when i try in any invoice to create a new items (an invoice hasMany items), when calling save i get error Èmber.Adapter must implement createRecord
Thanks for any help, could not find an answer here.
A Simplified version reproducing the problem on JSBIN
Index.html
<script type="text/x-handlebars" data-template-name="factures">
{{#each}}
<ul>
<li>{{#link-to 'facture' this}}
{{#if id}}
#{{id}}:{{title}}
{{else}}
#undefined:{{title}}
{{/if}}
{{/link-to}}</li>
</ul>
{{/each}}
<button {{ action 'newInvoice' }}>New Invoice using create() then save()</button>
<hr/>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="facture">
<h2>Items for {{title}}</h2>
{{#each items}}
<ul>
<li>{{desc}}</li>
</ul>
{{/each}}
<button {{ action 'newItem' }}>New Item using create() then save()</button>
</script>
Controller handling action
App.FactureController = Ember.ObjectController.extend({
actions: {
newItem: function(){
var items = this.get('model').get('items');
items.create({desc:"New Item"});
items.save();
}
}
});
App.FacturesController = Ember.ArrayController.extend({
actions: {
newInvoice: function(){
var facture = App.Facture.create({title:"New Invoice"}),
comment = facture.get('items').create({desc:"Sample Item"});
facture.save();
}
}
});