【发布时间】:2013-01-14 06:00:32
【问题描述】:
在 Rails 3.2 中,关联选项 counter_cache 是否链接到其他选项,例如 counter_sql 或 conditions?
例如,如果我有这样的关联:
class User
has_many :items, :through => :orders
has_many :active_items, :through => :orders
:conditions => 'active = true', :source => :item
class Order
belongs_to :users, :counter_cache => :active_items_count
belongs_to :items
class Item
has_many :users, :through => :orders
计数器缓存会遵守 active 条件吗? (意味着不活动的项目不会被计算在内)
那么使用finder_sql/counter_sql
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 associations counter-cache