FIX: Reflected post links were being deleted when they shouldn't and

vice versa.
This commit is contained in:
Robin Ward 2014-04-25 16:49:48 -04:00
parent b91c70cac3
commit 89df580560
1 changed files with 3 additions and 3 deletions

View File

@ -182,10 +182,10 @@ class TopicLink < ActiveRecord::Base
# Remove links that aren't there anymore
if added_urls.present?
TopicLink.delete_all ["(url not in (:urls)) AND (post_id = :post_id)", urls: added_urls, post_id: post.id]
TopicLink.delete_all ["(url not in (:urls)) AND (link_post_id = :post_id)", urls: reflected_urls, post_id: post.id]
TopicLink.delete_all ["(url not in (:urls)) AND (post_id = :post_id AND NOT reflection)", urls: added_urls, post_id: post.id]
TopicLink.delete_all ["(url not in (:urls)) AND (link_post_id = :post_id AND reflection)", urls: reflected_urls, post_id: post.id]
else
TopicLink.delete_all ["post_id = :post_id OR link_post_id = :post_id", post_id: post.id]
TopicLink.delete_all ["(post_id = :post_id AND NOT reflection) OR (link_post_id = :post_id AND reflection)", post_id: post.id]
end
end
end