Why would a record persisted successfully with a rest proxy calling the POST/Create action, and then on subsequent saves, call the same POST/Create method and not the the PUT/Update one?
POSTS
var ref = beginQuestionnaireControl.getPegfileRef();
var Pegfile = Ext.create('Pegfect.model.Pegfile', {
Id: 0,
Reference: ref
});
Pegfile.save({
scope: this,
success: function (pegfile, operation) {
this.activePegfile = pegfile;
this.startQuestions();
},
failure: function () {
alert('That ref is not unique');
}
});
also POSTS (expecting a PUT)
this.activePegfile.save({
success: function () {
successCallback();
},
failure: function () {
alert('oops, error saving Pegfile');
}
});
proxy
proxy:
{
type: 'rest',
url: 'Pegfile',
timeout: 120000,
noCache: false,
reader:
{
type: 'json',
root: 'data',
successProperty: 'success'
},
writer:
{
type: 'json',
writeAllFields: true
}
}
The trick is to define an ‘
Id‘ property on the Model:Crying out for some convention over config on this one…