From 11fa3f4a3c28268f439434615677eeb34999b4a8 Mon Sep 17 00:00:00 2001 From: Toks Date: Thu, 18 Jul 2013 15:06:30 -0400 Subject: [PATCH] Update tag_implication#update_posts_for_create * Remove "_for_create" from name, now that update_posts_for_destroy is removed * Use raw_tag_match instead of tag_match to avoid inconsistencies * Just append the implicated tags to the end of the tag string, rather than using regex --- app/models/tag_implication.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index 414d14e34..e2faa900c 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -110,7 +110,7 @@ class TagImplication < ActiveRecord::Base def process! update_column(:status, "processing") - update_posts_for_create + update_posts update_column(:status, "active") update_descendant_names_for_parent rescue Exception => e @@ -125,10 +125,9 @@ class TagImplication < ActiveRecord::Base end end - def update_posts_for_create - Post.tag_match("#{antecedent_name} status:any").find_each do |post| - escaped_antecedent_name = Regexp.escape(antecedent_name) - fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{antecedent_name} #{descendant_names} ").strip + def update_posts + Post.raw_tag_match(antecedent_name).find_each do |post| + fixed_tags = "#{post.tag_string} #{descendant_names}".strip CurrentUser.scoped(creator, creator_ip_addr) do post.update_attributes( :tag_string => fixed_tags