Sencha touch Sencha Touch 2 model.save正在使用POST而不是PUT更新操作

Sencha touch Sencha Touch 2 model.save正在使用POST而不是PUT更新操作,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,在sencha touch中,对现有记录的model.save()的2次调用触发的是POST,而不是预期的PUT 我有以下型号: Ext.define('HomeInventory.model.Product', { extend: 'Ext.data.Model', config: { idProperty: '_id', fields: [ { name: '_id', type: 'auto' },

在sencha touch中,对现有记录的model.save()的2次调用触发的是POST,而不是预期的PUT

我有以下型号:

Ext.define('HomeInventory.model.Product', {
    extend: 'Ext.data.Model',

    config: {
        idProperty: '_id',
        fields: [
            { name: '_id', type: 'auto' },
            { name: 'name', type: 'string' },
            { name: 'barcode', type: 'string' },
            { name: 'creationDate', type: 'date' },
            { name: 'currentAmount', type: 'number' },
            { name: 'isActive', type: 'boolean'}
        ],
        validations: [
            {type: 'presence', field: 'barcode', message: 'Barcode is required'},
            {type: 'presence', field: 'name', message: 'Name is required'}
        ],
        proxy :{
            type: 'rest',
            url: 'http://localhost:3000/products',
            actionMethods: {
                create: 'POST',
                read: 'GET',
                update: 'PUT',
                destroy: 'DELETE'
            },
        }
    }
});
json有效负载包含现有记录所需的_id字段,但使用HTTP POST而不是PUT发送到服务器:

{_id: "575bcd86c0eb22880c7e421e", name: "test product1", barcode: "1234", creationDate: null,…}
在控制器内保存函数调用:

submitProduct: function(){
    Ext.Viewport.setMasked({
        xtype: 'loadmask',
        indicator: true,
        message: 'Saving product...'
    });
    debugger;
    var product = Ext.create('HomeInventory.model.Product');
    this.getProductView().updateRecord(product);
    var validation = product.validate();
    if(validation.isValid){
        var me = this;
        product.save({
            success: function(){
                Ext.Viewport.unmask();
                me.returnToMain();
        },
        failure: function(){
            Ext.Viewport.unmask();
            Ext.Msg.alert('There was an error updating the product');
            me.returnToMain();
        }
      });
    }else{
        //Show validation error
    }
}

这里怎么了?

嗯,我找到了解决办法。在调用save方法之前,需要在产品上设置
phantom=false