ActsAsTaggableOn: Cache tag lists

Updated . Posted . Visible to the public.

For performance improvements (and to remove the need for eager loading), the ActsAsTaggableOn gem Show archive.org snapshot supports caching your tag lists directly in your model. To enable this, simply add a cached_tag_list column to your table.

Example:

class Company < ActiveRecord::Base
  acts_as_taggable_on :categories
end

The cache column has to be named cached_category_list.

Existing data

If you already have existing data, you have to save all records with tags once, after you've added the column, like this:

Company.all.each do |company|
  company.category_list # it seems you need to do this first to generate the list
  company.save!
end
Tobias Kraze
Last edit
Martin Straub
Keywords
include
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to makandra dev (2011-11-25 09:29)