cache_count

阅读更多
ruby 代码
  1. #thingsuser.rb   
  2. class Thingsuser < ActiveRecord::Base   
  3.     belongs_to :user  
  4.     belongs_to :thing:counter_cache => true     
  5. end  
ruby 代码
  1. #user.rb   
  2.   has_many :thingsusers  
  3.   has_many :things,:through=>:thingsusers,:dependent =>:destroy    
ruby 代码
  1. #thing.rb   
  2.   has_many :thingsusers  
  3.   has_many :users,  :through => :thingsusers  

 

table.column:thingsusers_count

你可能感兴趣的:(Cache,Ruby,ActiveRecord)