-
12 votesanswersviews
使用update_attribute运行Rails 3迁移时出现只读错误
我正在尝试添加一个counter_cache,这个Rails 3迁移给我一个我似乎无法解决的错误 . 迁移是 class AddItemsCountToStore < ActiveRecord::Migration def self.up add_column :stores, :items_count, :integer, :default => 0 ... -
3 votesanswersviews
Rails has_many通过多态计数器缓存
我有两个模型,我使用多态的has_many通过关联链接在一起,我想添加一个counter_cache但似乎Rails / ActiveRecord不支持开箱即用的这个功能 . class Classifiable < ActiveRecord::Base has_many :classifications, :as => :classifiable, :foreign_key =&...