I have a users and scores table. Here are the associations:
belongs_to :user #score model has_many :scores #user model
The users table has a column called scores_count . In this column, I store the sum of all the values in the scores table.
I wanted to use this method to store the sum of all scores in the scores_count: :counter_cache => true column scores_count: :counter_cache => true
But :counter_cache => true saving only the number of rows in the scores table. Is there any similar method for storing the sum of all values from a scores table? Or should I implement this task myself?
source share