Rails count_cache 与 XX_count

sforce100 · 2012年12月02日 · 最后由 sforce100 回复于 2012年12月03日 · 3041 次阅读

count_cache 与魔法字段 xxx_count 有什么关系呢? 另外 mongoid 能用定义了如下: class Topic include Mongoid::Document field :replies_count, :type => Integer, :default => 0 has_many :replies, :dependent => :destroy end class Reply include Mongoid::Document belongs_to :topic, :inverse_of => :replies end 保存 Reply.create(:topic => @topic._id)...但是@topic.replies_count还是等于 0

active_record 的 belongs_to 的 :counter_cache?

#1 楼 @vkill mongoid 不支持 counter_cache 的

#2 楼 @tumayun 借用了 ruby-china 的,不过还是谢谢咯

需要 登录 后方可回复, 如果你还没有账号请 注册新账号