fixes #1712
This commit is contained in:
@@ -16,6 +16,7 @@ class Post < ActiveRecord::Base
|
|||||||
before_save :set_tag_counts
|
before_save :set_tag_counts
|
||||||
before_validation :initialize_uploader, :on => :create
|
before_validation :initialize_uploader, :on => :create
|
||||||
before_validation :parse_pixiv_id
|
before_validation :parse_pixiv_id
|
||||||
|
before_validation :blank_out_nonexistent_parents
|
||||||
belongs_to :updater, :class_name => "User"
|
belongs_to :updater, :class_name => "User"
|
||||||
belongs_to :approver, :class_name => "User"
|
belongs_to :approver, :class_name => "User"
|
||||||
belongs_to :uploader, :class_name => "User"
|
belongs_to :uploader, :class_name => "User"
|
||||||
@@ -760,6 +761,12 @@ class Post < ActiveRecord::Base
|
|||||||
m.extend(ClassMethods)
|
m.extend(ClassMethods)
|
||||||
end
|
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
|
def validate_parent_does_not_have_a_parent
|
||||||
return if parent.nil?
|
return if parent.nil?
|
||||||
if !parent.parent.nil?
|
if !parent.parent.nil?
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if post.parent_id %>
|
<% if post.parent_id && post.parent %>
|
||||||
<div class="ui-corner-all ui-state-highlight notice notice-child">
|
<div class="ui-corner-all ui-state-highlight notice notice-child">
|
||||||
<%= has_parent_message(post, @parent_post_set) %>
|
<%= has_parent_message(post, @parent_post_set) %>
|
||||||
<div id="has-parent-relationship-preview"><%= @parent_post_set.presenter.post_previews_html(self) %></div>
|
<div id="has-parent-relationship-preview"><%= @parent_post_set.presenter.post_previews_html(self) %></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user