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