ruby 代碼
- #thingsuser.rb
- class Thingsuser < ActiveRecord::Base
- belongs_to :user
- belongs_to :thing, :counter_cache => true
- end
ruby 代碼
- #user.rb
- has_many :thingsusers
- has_many :things,:through=>:thingsusers,:dependent =>:destroy
ruby 代碼
- #thing.rb
- has_many :thingsusers
- has_many :users, :through => :thingsusers
table.column:thingsusers_count