bug fix on saving chal

This commit is contained in:
Tyler Renelle
2013-11-04 09:02:22 -08:00
parent 63b4e5152e
commit 7161ddf70e

View File

@@ -47,7 +47,7 @@ ChallengeSchema.methods.toJSON = function(){
// --------------
function syncableAttrs(task) {
var t = task.toObject(); // lodash doesn't seem to like _.omit on EmbeddedDocument
var t = (task.toObject) ? task.toObject() : task; // lodash doesn't seem to like _.omit on EmbeddedDocument
// only sync/compare important attrs
var omitAttrs = 'history tags completed streak'.split(' ');
if (t.type != 'reward') omitAttrs.push('value');
@@ -67,7 +67,7 @@ function comparableData(obj) {
.toString(); // for comparing arrays easily
}
ChallengeSchema.isOutdated = function(newData) {
ChallengeSchema.methods.isOutdated = function(newData) {
return comparableData(this) !== comparableData(newData);
}