acts-as-taggable-on 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.3
1
+ 1.1.4
@@ -158,7 +158,7 @@ module ActiveRecord
158
158
  conditions << "#{table_name}.#{primary_key} IN (SELECT #{Tagging.table_name}.taggable_id FROM #{Tagging.table_name} JOIN #{Tag.table_name} ON #{Tagging.table_name}.tag_id = #{Tag.table_name}.id AND (#{tags_conditions}) WHERE #{Tagging.table_name}.taggable_type = #{quote_value(base_class.name)})"
159
159
 
160
160
  else
161
- tags = Tag.named_like_any(tag_list)
161
+ tags = Tag.named_any(tag_list)
162
162
  return { :conditions => "1 = 0" } unless tags.length == tag_list.length
163
163
 
164
164
  tags.each do |tag|
@@ -380,11 +380,11 @@ module ActiveRecord
380
380
  :order => "count DESC"
381
381
  }.update(options)
382
382
  end
383
-
383
+
384
384
  def save_cached_tag_list
385
385
  self.class.tag_types.map(&:to_s).each do |tag_type|
386
- if self.class.send("caching_#{tag_type.singularize}_list?")
387
- self["cached_#{tag_type.singularize}_list"] = tag_list_cache_on(tag_type.singularize).tags.join(', ')
386
+ if self.class.send("caching_#{tag_type.singularize}_list?")
387
+ self["cached_#{tag_type.singularize}_list"] = tag_list_cache_on(tag_type.singularize).to_a.flatten.compact.join(', ')
388
388
  end
389
389
  end
390
390
  end
@@ -403,17 +403,21 @@ module ActiveRecord
403
403
  # Destroy old taggings:
404
404
  if owner
405
405
  old_tags = tags_on(context, owner) - new_tags
406
- old_taggings = Tagging.find(:all, :conditions => { :taggable_id => self.id, :taggable_type => self.class.to_s, :tag_id => old_tags, :tagger_id => owner, :tagger_type => owner.class.to_s, :context => context })
406
+ old_taggings = Tagging.find(:all, :conditions => { :taggable_id => self.id, :taggable_type => self.class.to_s, :tag_id => old_tags, :tagger_id => owner.id, :tagger_type => owner.class.to_s, :context => context })
407
407
 
408
- old_taggings.each(&:destroy)
409
- else
408
+ Tagging.destroy_all :id => old_taggings.map(&:id)
409
+ else
410
410
  old_tags = tags_on(context) - new_tags
411
411
  base_tags.delete(*old_tags)
412
412
  end
413
-
414
- new_tags.reject! { |tag| taggings.any? { |tagging| tagging.tag == tag &&
415
- tagging.tagger == owner &&
416
- tagging.context == context } }
413
+
414
+ new_tags.reject! { |tag| taggings.any? { |tagging|
415
+ tagging.tag_id == tag.id &&
416
+ tagging.tagger_id == (owner ? owner.id : nil) &&
417
+ tagging.tagger_type == (owner ? owner.class.to_s : nil) &&
418
+ tagging.context == context
419
+ }
420
+ }
417
421
 
418
422
  # create new taggings:
419
423
  new_tags.each do |tag|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-taggable-on
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-07 00:00:00 +01:00
12
+ date: 2010-02-13 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15