malkomalko
8/15/2009 - 4:40 PM

gistfile1.txt

createRecord: function(store, storeKey) {
  
    var dataHash = store.readDataHash(storeKey), 
      obj={"content":dataHash,
        "authenticity_token":SC.RAILS_AUTH_TOKEN};
      
    var r = SC.Request.postUrl('tasks').set('isJSON', YES);
  
    r.notify(this, this.createRecordDidComplete, { 
      store: store, storeKey: storeKey
    }).send(obj);
  
    this.cancelStoreKeys[storeKey]=[].push(r);
  
    return YES ;
  },
  
  createRecordDidComplete: function(r, params) {
  
    var response, results, guid;
    response = r.response();
    
    if(response.kindOf ? response.kindOf(SC.Error) : false) {
      this.requestDidError(r);
    } else {
      results = response.content;
      guid=results.guid;
      params.store.dataSourceDidComplete(params.storeKey, results, guid);
      this.cancelStoreKeys[params.storeKey]=null;
    }
  
    return YES;
  },