Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed bug with tagnames caching

  • Loading branch information...
commit 2e74dbd03b11f0d088fe9a35b0e0c0d9ba1766d7 1 parent bdd88b0
Kevin Watt authored Wesley Beary committed
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/acts_as_taggable.rb
View
9 lib/acts_as_taggable.rb
@@ -74,9 +74,12 @@ def find_related_tags(tags, options = {})
end
module InstanceMethods
+ # Warning: Not updated until save is called!
+ # hmm, want to update cache before the item is saved so we don't have to do another query
def tag_list=(new_tag_list)
unless tag_list == new_tag_list
- @new_tag_list = new_tag_list
+ @new_tag_list = Tag.parse(new_tag_list)
+ self.tagnames = @new_tag_list.join(', ') if has_attribute?("tagnames")
end
end
@@ -97,6 +100,7 @@ def tag_list(user = nil)
def update_tags
if @new_tag_list
Tag.transaction do
+ # this needs commenting. why only remove tags for the user?
unless @new_user_id
taggings.destroy_all
else
@@ -105,7 +109,8 @@ def update_tags
end
end
- Tag.parse(@new_tag_list).each do |name|
+ #moved parse into tag_list = so we can assign to tagnames if present for caching
+ @new_tag_list.each do |name|
Tag.find_or_create_by_name(name).tag(self, @new_user_id)
end
Please sign in to comment.
Something went wrong with that request. Please try again.