From f213dea529adfc4fd1c6b9289492f18d587ed21d Mon Sep 17 00:00:00 2001
From: scossar <scossar3@gmail.com>
Date: Tue, 20 Mar 2018 12:13:41 -0700
Subject: [PATCH] Make sure a post has replies before accessing the reply id

---
 app/views/embed/comments.html.erb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/views/embed/comments.html.erb b/app/views/embed/comments.html.erb
index 23f69584fed..b6863c21aab 100644
--- a/app/views/embed/comments.html.erb
+++ b/app/views/embed/comments.html.erb
@@ -27,7 +27,7 @@
         </h3>
         <%= get_html(post.cooked) %>
 
-        <%- if post.reply_count > 0 %>
+        <%- if post.reply_count > 0 && post.replies.exists? %>
           <%- if post.reply_count == 1 %>
             <%= link_to I18n.t('embed.replies', count: post.reply_count), post.full_url, 'data-link-to-post' => post.replies.first.id.to_s, :class => 'post-replies button' %>
           <% else %>