내 경로 중 하나에이 항목이 있습니다.왜 사용자 ID를 설정할 수 없습니까?
Error: Assertion Failed: Error: The backend rejected the commit because it was invalid: {userId: can't be blank}
그리고 API 페이로드는 다음과 같습니다 : console.log(user.get('id'));
는 user
이어야 나타내는 사용자의 ID를 가져옵니다 때문에
{"order":{"user_id":null,"product_id":"30"}}
그것은 이상한
var order = _this.store.createRecord('order');
order.set('product', product);
this.store.find('userProfile', 1).then(function(user) {
console.log(user.get('id'));
order.set('user', user);
});
order.save().then(function() {
_this.transitionTo('products.index');
});
나는이 오류 올바른 대상.
사용자 ID가 설정되지 않은 것으로 보입니다.
import DS from 'ember-data';
export default DS.Model.extend({
user: DS.belongsTo('userProfile'),
product: DS.belongsTo('product')
});
내가 뭔가를 놓친 건가 :
내 Order
모델처럼 보이는 어떤 correclty을 실행하지 않는 order.set('user', user);
을 의미 ...?
당신이 ActiveModel 어댑터를 사용하고 있습니까? – Sushant
예, ActiveModelAdapter –