diff --git a/app/serializers/category_detailed_serializer.rb b/app/serializers/category_detailed_serializer.rb index 531c01435..b1d68d1be 100644 --- a/app/serializers/category_detailed_serializer.rb +++ b/app/serializers/category_detailed_serializer.rb @@ -72,7 +72,11 @@ class CategoryDetailedSerializer < BasicCategorySerializer end def count_with_subcategories(method) - object.subcategories.inject(object.send(method) || 0) { |sum,c| sum += (c.send(method) || 0) } + count = object.send(method) || 0 + object.subcategories.each do |category| + count += (object.send(method) || 0) + end + count end end