PDA

View Full Version : How to call Rails update ?



redjetfire
10 Oct 2012, 3:23 AM
updateSettings: function()
{
console.log("Submit Settings button clicked");
var win = Ext.getCmp('profilesett'),
val = win.down('form').getForm().getFieldValues();
console.log(val);
var rec = Ext.create('GUMAS.model.Profile', val);
var store = this.getProfilesStore();
store.removeAll();
store.add(rec);
store.save({
success: function(req, res){
win.close();
Ext.MessageBox.alert('Success', 'Your profile data has been successfully saved.');
},
failure: function(req, res)
{
Ext.MessageBox.alert('Error', 'Password does not changed.');
}
});
},

Ext.define('GUMAS.store.Profiles',{
extend: 'Ext.data.Store',
model: 'GUMAS.model.Profile',

proxy: {
type: 'rest',
url: '/profiles/',
reader: {
type: 'json',
root: 'profiles',
idProperty: 'id',
successProperty: 'success'
},
writer: {
encoding: false,
type: 'json',
successProperty: 'success'
}
}
});

How can I call Rails PUT (update) with updateSettings function instead of store.save ???

mitchellsimoens
15 Oct 2012, 6:47 AM
store.sync() ?