fixes #1970
This commit is contained in:
@@ -18,6 +18,7 @@ class Post < ActiveRecord::Base
|
||||
before_validation :initialize_uploader, :on => :create
|
||||
before_validation :parse_pixiv_id
|
||||
before_validation :blank_out_nonexistent_parents
|
||||
before_validation :remove_parent_loops
|
||||
belongs_to :updater, :class_name => "User"
|
||||
belongs_to :approver, :class_name => "User"
|
||||
belongs_to :uploader, :class_name => "User"
|
||||
@@ -814,6 +815,13 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def remove_parent_loops
|
||||
if parent.present? && parent.parent_id == id
|
||||
parent.parent_id = nil
|
||||
parent.save
|
||||
end
|
||||
end
|
||||
|
||||
def validate_parent_does_not_have_a_parent
|
||||
return if parent.nil?
|
||||
if !parent.parent.nil?
|
||||
|
||||
Reference in New Issue
Block a user