-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Home
Kunal Shah edited this page Oct 10, 2015
·
12 revisions
- Blog Post: http://www.intridea.com/2007/12/4/announcing-acts_as_taggable_on
- API: http://rubydoc.info/gems/acts-as-taggable-on/
- Screencast: http://railscasts.com/episodes/382-tagging
To change the tag list delimiter, do this in your config/initializers/acts_as_taggable_on.rb:
ActsAsTaggableOn.delimiter = ' ' # use space as delimiter
If you would like to remove unused tag objects after removing taggings, add
ActsAsTaggableOn.remove_unused_tags = true
If you want force tags to be saved downcased:
ActsAsTaggableOn.force_lowercase = true
If you want tags to be saved parametrized (you can redefine to_param as well):
ActsAsTaggableOn.force_parameterize = true
If you want tags to be matched case-sensitively:
ActsAsTaggableOn.strict_case_match = true
ActsAsTaggableOn updates a counter cache on tagging operations between the Tag and Tagging model. If you are encountering deadlocks, perhaps while tagging many ActiveRecord objects in a queue, you can turn disable the tag counter cache:
ActsAsTaggableOn.tags_counter = false
and reset counters afterward with:
ActsAsTaggableOn::Tag.pluck(:id).each do |id|
ActsAsTaggableOn::Tag.reset_counters(id, :taggings)
end
An alternate solution is calculating the counter cache less often and asynchronously using a queue.