如何使用acts_as_taggable_on缓存标签? [英] How to cache tags with acts_as_taggable_on?

查看:69
本文介绍了如何使用acts_as_taggable_on缓存标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有标签上下文的模型:

I have model with tag context:

class Product < ActiveRecord::Base
  acts_as_taggable_on :categories
end

我正在尝试初始化标签缓存:

I'm trying to initialize tags caching:

class AddCachedCategoryListToProducts < ActiveRecord::Migration
  def self.up
    add_column :products,  :cached_category_list, :string
    Product.reset_column_information
    products = Product.all
    products.each { |p| p.save_cached_tag_list }
  end
end

但是 cached_category_list 不初始化。我做错了什么?有人可以使用此gem缓存(我的版本是2.0.6)吗?

But cached_category_list does not initializing. What I'm doing wrong? Does anybody can use caching with this gem (my version is 2.0.6)?

推荐答案

如果与以下选项结合使用拥有的标签,这可能是问题所在。
查看gem的代码,似乎不支持对自有标签进行缓存

If you are using this in combination with owned tags, that might be the problem. Looking at the code of the gem, it seems that the caching of owned tags isn't support

希望这会有所帮助,

最好,
J

Best, J

这篇关于如何使用acts_as_taggable_on缓存标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆