Skip to content

Instantly share code, notes, and snippets.

@skizzybiz
skizzybiz / rails.js
Created May 3, 2011 19:23
DataSource update methods
updateRecord: function(store, storeKey) {
var data, id, recordType, request;
recordType = store.recordTypeFor(storeKey);
id = store.idFor(storeKey);
data = this.formatData(store.readDataHash(storeKey), recordType);
console.log("storeKey = " + storeKey);
console.log("store.readDataHash(" + storeKey + ") = ");
console.log(store.readDataHash(storeKey));
request = SC.Request.putUrl("" + recordType.RESOURCE_PATH + "/" + id);
SC.ready(function() {
var records;
MT.mainPane = SC.TemplatePane.append({
layerId: 'my_app',
templateName: 'my_app'
});
records = MT.MyRecord.originals();
MT.myRecords.set('content', records);
return MT.myRecords.selectObject(records.objectAt(0));
});
> e = MT.store.find(MT.WhitelistEntry, 1)
Object
> e.get('reportTemplate').get('id')
1
> t = MT.store.find(MT.ReportTemplate, 1)
Object
> t.get('whitelistEntries').length()
0
@skizzybiz
skizzybiz / whitelist_entry_test.js
Created April 19, 2011 19:56
broken SproutCore unit test
// This works:
module("MessageTracer.WhitelistEntry");
test("test description", function() {
var expected, result;
expected = "test";
result = "test";
return equals(result, expected, "test should equal test");
});