better explicit check for existence of parent

This commit is contained in:
r888888888
2013-06-05 15:04:31 -07:00
parent ca5cdb18fc
commit 4bbfc307c3
2 changed files with 5 additions and 1 deletions

View File

@@ -820,6 +820,10 @@ class Post < ActiveRecord::Base
false
end
end
def parent_exists?
Post.exists?(parent_id)
end
end
module DeletionMethods

View File

@@ -46,7 +46,7 @@
</div>
<% end %>
<% if post.parent_id && post.parent %>
<% if post.parent_id && post.parent_exists? %>
<div class="ui-corner-all ui-state-highlight notice notice-child">
<%= has_parent_message(post, @parent_post_set) %>
<div id="has-parent-relationship-preview"><%= @parent_post_set.presenter.post_previews_html(self) %></div>