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:
Bertocq
2018-01-31 01:46:47 +01:00
parent 033c197580
commit 4ec30a9082

View File

@@ -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