# Acts\_as\_taggable\_on\_steroids and cached\_tag\_list

**URL:** <https://www.ruby-forum.com/t/acts-as-taggable-on-steroids-and-cached-tag-list/134711>\
**Category:** Rails\
**Created:** [April 14, 2008, 12:02pm UTC](https://www.ruby-forum.com/t/acts-as-taggable-on-steroids-and-cached-tag-list/134711 "2008-04-14T12:02:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![codeofficer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b2d939/32.png) [@codeofficer](https://www.ruby-forum.com/u/codeofficer)\
**Post date:** [April 14, 2008, 12:02pm UTC](https://www.ruby-forum.com/t/acts-as-taggable-on-steroids-and-cached-tag-list/134711/1 "2008-04-14T12:02:54Z")

</div>

Just posting a solution (which started a problem I was going to post  
about)

I’m using acts\_as\_taggable\_on\_steroids with rails 2.0.1

When I would add tags (via a form) to my model they would go straight  
to that models cached\_tag\_list field as expected, but the tags and  
associations would never get saved to my tags and taggings tables.  
However, playing in console … they would get saved fine!

I managed to figure out that i needed to add a

before\_save ‘self.save\_tags’

to my ‘acts\_as\_taggable’ model … after i did this associations were  
saving fine to both places …

I am confused though … as to why i would have to add this  
callback … from what I can tell the plugin is supposed to do this  
already, confusing. Anyone know why the plugin doesn’t do both?

from its source … i see

```
    def save_tags
      return unless @tag_list

      new_tag_names = @tag_list - tags.map(&:name)
      old_tags = tags.reject { |tag| @tag_list.include?

```

(tag.name) }

```
      self.class.transaction do
        if old_tags.any?
          taggings.find(:all, :conditions => ["tag_id IN (?)",

```

old\_tags.map(&:id)]).each(&:destroy)  
taggings.reset  
end

```
        new_tag_names.each do |new_tag_name|
          tags <<

```

Tag.find\_or\_create\_with\_like\_by\_name(new\_tag\_name)  
end  
end

```
      true
    end

```

i was able to deduce that its returning because of @tag\_list … and  
not executing a normal save … I asssume somewhere else that means  
@tag\_list is being cleared, perhaps after the cached version is saved.
