Render enterprise rows as a collection

Note: this is a bit like an N+1 query, but for rendering. If there are 30 enterprises, the partial file would be loaded and parsed 30 times; but if we render it as a collection it'll load the partial once and substantially improve the performance.
This commit is contained in:
Matt-Yorkley
2021-05-18 20:09:54 +01:00
parent 5f9679655c
commit 0c4e191f3b

View File

@@ -25,8 +25,7 @@
%span.centered.three.columns
= t "spree_admin_enterprises_fees"
%div.sixteen.columns.alpha.list
- @enterprises.each do |enterprise|
= render 'enterprise_row', { enterprise: enterprise }
= render partial: 'enterprise_row', collection: @enterprises, as: :enterprise
%a.sixteen.columns.alpha.button.bottom.blue{ href: "#{main_app.admin_enterprises_path}" }
= t "spree_admin_overview_enterprises_footer"