【问题标题】:Emberjs: updating belongsTo doesn't send id to the APIEmberjs:更新 belongsTo 不会将 id 发送到 API
【发布时间】:2014-12-22 10:48:59
【问题描述】:

我正在尝试更新模型的 belongsTo 关系,但 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 一切都很好。

【问题讨论】:

    标签: javascript ember.js ember-data


    【解决方案1】:

    通过将 ember-data 升级到 1.0.0.beta.12 解决了这个问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-01
      • 2011-09-08
      相关资源
      最近更新 更多