This commit is contained in:
r888888888
2013-06-05 14:43:45 -07:00
parent 0fcdc271a9
commit 518c2ea52d
2 changed files with 8 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ class Post < ActiveRecord::Base
before_save :set_tag_counts
before_validation :initialize_uploader, :on => :create
before_validation :parse_pixiv_id
before_validation :blank_out_nonexistent_parents
belongs_to :updater, :class_name => "User"
belongs_to :approver, :class_name => "User"
belongs_to :uploader, :class_name => "User"
@@ -760,6 +761,12 @@ class Post < ActiveRecord::Base
m.extend(ClassMethods)
end
def blank_out_nonexistent_parents
if parent_id.present? && parent.nil?
self.parent_id = nil
end
end
def validate_parent_does_not_have_a_parent
return if parent.nil?
if !parent.parent.nil?

View File

@@ -46,7 +46,7 @@
</div>
<% end %>
<% if post.parent_id %>
<% if post.parent_id && post.parent %>
<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>