Skip to content

Instantly share code, notes, and snippets.

Andrei Soare andreisoare

Block or report user

Report or block andreisoare

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View RESTAdapter.js
didCreateRecord: function(record, data) {
var rootKey = get(record.constructor, 'rootKey'),
primaryKey = get(record.constructor, 'primaryKey'),
dataToLoad = rootKey ? data[rootKey] : data;
record.set(primaryKey, dataToLoad[primaryKey]); // setting the id returned by the server
record.load(dataToLoad[primaryKey], dataToLoad);
record.didCreateRecord();
},
View Model.all().js
all: function() {
var records = Ember.RecordArray.create({
modelClass: this,
content: []
});
var cache = this.recordCache;
if (!cache) { return records; }
Object.keys(cache).forEach(function(id) {
records.addObject(cache[id]);
});
You can’t perform that action at this time.