From 4bbfc307c332a5c320462daed4fad099e218c255 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Wed, 5 Jun 2013 15:04:31 -0700 Subject: [PATCH] better explicit check for existence of parent --- app/models/post.rb | 4 ++++ app/views/posts/partials/show/_notices.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index baf592c7f..793fa4a35 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -820,6 +820,10 @@ class Post < ActiveRecord::Base false end end + + def parent_exists? + Post.exists?(parent_id) + end end module DeletionMethods diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index 9ab1d7e88..a64abab20 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -46,7 +46,7 @@ <% end %> -<% if post.parent_id && post.parent %> +<% if post.parent_id && post.parent_exists? %>
<%= has_parent_message(post, @parent_post_set) %>
<%= @parent_post_set.presenter.post_previews_html(self) %>