Avoid using comments_count counter_cache at Investment
As Budget::Investment has two relationships over commentable polymorphic relationship, the counter_cache is counting the sum of both comments and valuations. We don't show valuations count anywhere, only the (public) comments so we just use comments.count in this case
This commit is contained in:
@@ -89,6 +89,10 @@ class Budget
|
||||
before_validation :set_responsible_name
|
||||
before_validation :set_denormalized_ids
|
||||
|
||||
def comments_count
|
||||
comments.count
|
||||
end
|
||||
|
||||
def url
|
||||
budget_investment_path(budget, self)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user