From 7161ddf70ebe9f054390d3cd4e70ef5963c8e9b2 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Mon, 4 Nov 2013 09:02:22 -0800 Subject: [PATCH] bug fix on saving chal --- src/models/challenge.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/challenge.js b/src/models/challenge.js index 9b7ba894fc..d00e533631 100644 --- a/src/models/challenge.js +++ b/src/models/challenge.js @@ -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); }