#1970: Fix bug for new uploads

This commit is contained in:
Toks
2013-10-20 20:13:03 -04:00
parent d5cf4cd8bd
commit 397e130f5a

View File

@@ -464,8 +464,9 @@ class Post < ActiveRecord::Base
self.parent_id = nil self.parent_id = nil
when /^parent:(\d+)$/i when /^parent:(\d+)$/i
if $1.to_i != id && Post.exists?(["id = ?", $1.to_i]) && Post.find($1.to_i).parent_id != id if $1.to_i != id && Post.exists?(["id = ?", $1.to_i])
self.parent_id = $1.to_i self.parent_id = $1.to_i
remove_parent_loops
end end
when /^rating:([qse])/i when /^rating:([qse])/i
@@ -816,7 +817,7 @@ class Post < ActiveRecord::Base
end end
def remove_parent_loops def remove_parent_loops
if parent.present? && parent.parent_id == id if parent.present? && parent.parent_id.present? && parent.parent_id == id
parent.parent_id = nil parent.parent_id = nil
parent.save parent.save
end end