我有以下型号:
App.ApplianceType = DS.Model.extend
name: DS.attr('string')
description: DS.attr('string')
author: DS.belongsTo('user')
author_name: (->
console.debug 'author >>> %o', @get('author')
if @get('author') == null
'anonymous'
else
@get('author.login')
).property 'author.login'
App.User = DS.Model.extend
login: DS.attr('string')
appliance_types: DS.hasMany('appliance_type', { inverse: 'author' })
一切都按预期工作,但有一个例外:在保存ApplianceType模型后(@get('content').save()
)belongsTo
将作者的关系设置为作者ID而不是author
模型。
author >>> <App.User:ember427:3> //presenting appliance_type
PUT http://localhost:3000/api/v1/appliance_types/20 200 OK //saving appliance type
author >>> 3 //updating author login after save
问题与PUT调用返回的有效负载有关:
{"appliance_type":{
"id":20,
"name":"aaaasss",
"description":"asdfasdfsd **aaaa**",
"author":3
}}
将有效负载更改为{}
后一切正常 - 记录未更新。是emberjs / ember-data中的预期行为还是错误?
emberjs 1.0.0
,ember-data 1.0.0.beta.2
更新
有关