From bfefda06f6f2bb3460ac68dbbe0c28e5f4509fc5 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Thu, 25 Aug 2016 06:57:00 +0530 Subject: [PATCH] FIX: handle embed count when topic not found --- app/controllers/embed_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rb index f9daccb4883..3286eaead1b 100644 --- a/app/controllers/embed_controller.rb +++ b/app/controllers/embed_controller.rb @@ -69,7 +69,11 @@ class EmbedController < ApplicationController topic_embeds.each do |te| url = te.embed_url url = "#{url}#discourse-comments" unless params[:embed_url].include?(url) - by_url[url] = I18n.t('embed.replies', count: te.topic.posts_count - 1) + if te.topic.present? + by_url[url] = I18n.t('embed.replies', count: te.topic.posts_count - 1) + else + by_url[url] = I18n.t('embed.replies', count: 0) + end end end