我需要为has_one关联禁用计数器缓存,如下所示,并将其保留在 has_many 上:
class User < ActiveRecord::Base
has_one :email, as: :emailable
end
class Company < ActiveRecord::Base
has_many :emails, as: :emailable
end
class Email < ActiveRecord::Base
belongs_to :emailable, polymorphic: true, counter_cache: emails_count
end
我在用户模型上没有emails_count列。有任何想法吗?
谢谢你的帮助!