#Задача - показать количество продуктов в списке категорий ##Controllers
nodes_controller.rb
def index
@items = Node.includes(:cluster => [:team]).by_filter(@filter)
# for count
node_ids = Node.pluck(:id)
@containers_count = ClusterContainer.where(:node_id => node_ids).group(:node_id).count
end
##View
nodes/index.html.haml
...
%table.table.table-striped.table-bordered.table-hover
%tr
...
%th Containers
- @items.each do |item|
...
%td
= link_to admin_cluster_containers_path(:node_id => item.id) do
containers
%span
(#{@containers_count[item.id] || 0})