From 406b1ecf5b6d513ab97bc5157335b6124367dc36 Mon Sep 17 00:00:00 2001 From: kero-uzura Date: Mon, 22 Jan 2018 21:04:09 +0900 Subject: [PATCH] fix scores count --- app/models/score.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/score.rb b/app/models/score.rb index 4668edfa..69d91d99 100644 --- a/app/models/score.rb +++ b/app/models/score.rb @@ -6,7 +6,9 @@ class Score < ApplicationRecord belongs_to :user, optional: true has_many :favs, dependent: :destroy - counter_culture :user, column_names: { ["scores.status = ?", '0'] => :scores_count } + counter_culture :user, + column_name: -> (score) { score.published? ? :scores_count : nil }, + column_names: { ["scores.status = ?", '0'] => :scores_count } paginates_per 20