diff --git a/models/User.js b/models/User.js index cb6c0f2b0..37558d1da 100644 --- a/models/User.js +++ b/models/User.js @@ -60,7 +60,7 @@ UserSchema.methods.toProfileJSONFor = function(user){ UserSchema.methods.favorite = function(id){ if(this.favorites.indexOf(id) === -1){ - this.favorites.push(id); + this.favorites = this.favorites.concat([id]); } return this.save(); @@ -79,7 +79,7 @@ UserSchema.methods.isFavorite = function(id){ UserSchema.methods.follow = function(id){ if(this.following.indexOf(id) === -1){ - this.following.push(id); + this.following = this.following.concat([id]); } return this.save(); diff --git a/routes/api/articles.js b/routes/api/articles.js index e0f1074ba..c17ca6145 100644 --- a/routes/api/articles.js +++ b/routes/api/articles.js @@ -254,7 +254,7 @@ router.post('/:article/comments', auth.required, function(req, res, next) { comment.author = user; return comment.save().then(function(){ - req.article.comments.push(comment); + req.article.comments = req.article.comments.concat([comment]); return req.article.save().then(function(article) { res.json({comment: comment.toJSONFor(user)});