disable Tag.find_or_create_by_name for single tag queries with no matching tag record

This commit is contained in:
albert
2013-03-31 18:27:32 -04:00
parent 0e052f2fd7
commit ce7d6bc0dd
2 changed files with 3 additions and 4 deletions

View File

@@ -318,8 +318,8 @@ class Post < ActiveRecord::Base
increment_tags = tag_array - tag_array_was
execute_sql("UPDATE tags SET post_count = post_count - 1 WHERE name IN (?)", decrement_tags) if decrement_tags.any?
execute_sql("UPDATE tags SET post_count = post_count + 1 WHERE name IN (?)", increment_tags) if increment_tags.any?
Post.expire_cache_for_all(decrement_tags)
Post.expire_cache_for_all(increment_tags)
Post.expire_cache_for_all(decrement_tags) if decrement_tags.any?
Post.expire_cache_for_all(increment_tags) if increment_tags.any?
Post.expire_cache_for_all([""]) if new_record? || id <= 100_000
end

View File

@@ -49,8 +49,7 @@ module PostSetPresenters
if tag
tag.related_tag_array.map(&:first)
else
tag = Tag.find_or_create_by_name(post_set.tag_string)
tag.related_tag_array.map(&:first)
[]
end
end