0

今のところ、ember-model と hasMany 関係を使用して、FixtureAdapter を使用して請求アプリを構築しようとしています。新しい請求書レコードを作成しようとすると、エラーなしで新しい請求書を取得できますが、ID がまったくありません (未定義です)。ID 作成をサーバー側で処理する必要がありますか? :/ そして、請求書で新しいアイテムを作成しようとすると (請求書には多くのアイテムがあります)、保存を呼び出すとエラーが発生しますÈmber.Adapter must implement createRecord

助けてくれてありがとう、ここで答えを見つけることができませんでした。

JSBINの問題を再現した簡易版

索引.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>

コントローラーハンドリングアクション

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();
      }
    }
});
4

1 に答える 1