Rails count_cache 与 XX_count

sforce100 · December 02, 2012 · Last by sforce100 replied at December 03, 2012 · 3041 hits

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 的,不过还是谢谢咯

You need to Sign in before reply, if you don't have an account, please Sign up first.