BUGFIX: error when find_similar_to has no response

This commit is contained in:
Régis Hanol 2014-01-21 19:32:37 +01:00
parent a524194a46
commit 0bb02505b0
1 changed files with 5 additions and 1 deletions

View File

@ -318,7 +318,11 @@ Discourse.Topic.reopenClass({
**/ **/
findSimilarTo: function(title, body) { findSimilarTo: function(title, body) {
return Discourse.ajax("/topics/similar_to", { data: {title: title, raw: body} }).then(function (results) { return Discourse.ajax("/topics/similar_to", { data: {title: title, raw: body} }).then(function (results) {
return results.map(function(topic) { return Discourse.Topic.create(topic); }); if (Array.isArray(results)) {
return results.map(function(topic) { return Discourse.Topic.create(topic); });
} else {
return Ember.A();
}
}); });
}, },