Emberjs:更新 belongsTo 不会将 id 发送到 API

Emberjs: updating belongsTo doesn't send id to the API

本文关键字:id API 更新 belongsTo Emberjs      更新时间:2023-09-26

>我正在尝试更新模型的归属关系,但 Ember 不会将 category_id 属性发送到 API,除非我将 async 设置为 false 我不想要。

这是我的模型:

App.reopen
  Category: DS.Model.extend(
    name: DS.attr('string')
  )
  Product: DS.Model.extend(
    category: DS.belongsTo('category', async: true)
  )

这里有一个类似的例子,说明我如何尝试更新产品。

@store.find('category', 1).then (category) ->
  product.set('category', category)
  product.save()

查看我的 API 日志时,没有给出category_id属性。如果我从模型定义中删除async: true,一切都很好。

通过将 ember 数据升级到 1.0.0.beta.12 来解决此问题