我有桌子users和scores。以下是关联:
belongs_to :user #score model
has_many :scores #user model
该表users具有名为 的列scores_count。在此列中,我存储表中所有值的总和scores。
我想用这种方式将所有的总和存储scores在列中scores_count: :counter_cache => true
但:counter_cache => true只保存表中的行数scores。有没有类似的方法来存储表中所有值的总和scores?还是我必须自己执行此任务?