From 98c8bdc0bb41071154d49cbcb7846adddbf2f50e Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Mon, 27 Apr 2026 00:37:51 +0930 Subject: [PATCH] Merge pull request #4564 from Growstuff/memory-optimization-2149092598558110155 Memory usage optimization --- app/views/alternate_names/_form.html.haml | 4 ++-- app/views/crops/_form.html.haml | 2 +- app/views/scientific_names/_form.html.haml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/alternate_names/_form.html.haml b/app/views/alternate_names/_form.html.haml index dab8a7c1d..fdfe71a63 100644 --- a/app/views/alternate_names/_form.html.haml +++ b/app/views/alternate_names/_form.html.haml @@ -22,8 +22,8 @@ .form-group = f.label :crop_id, class: 'control-label col-md-2' .col-md-8 - = collection_select(:alternate_name, :crop_id, - Crop.all, :id, :name, + = select(:alternate_name, :crop_id, + Crop.order(:name).pluck(:name, :id), { selected: @alternate_name.crop_id || @crop.id }, class: 'form-control') diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index 6fc3849c4..8ada38479 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -85,7 +85,7 @@ -# Only crop wranglers see the crop hierarchy (for now) - if can? :wrangle, @crop - = f.collection_select(:parent_id, Crop.all.order(:name), :id, :name, + = f.select(:parent_id, Crop.order(:name).pluck(:name, :id), { include_blank: true, label: 'Parent crop'}) %span.help-block Optional. For setting up crop hierarchies for varieties etc. diff --git a/app/views/scientific_names/_form.html.haml b/app/views/scientific_names/_form.html.haml index 912f40135..4769bce42 100644 --- a/app/views/scientific_names/_form.html.haml +++ b/app/views/scientific_names/_form.html.haml @@ -17,8 +17,8 @@ .form-group = f.label :crop_id, class: 'control-label col-md-2' .col-md-8 - = collection_select(:scientific_name, :crop_id, Crop.all.order(:name), :id, - :name, { selected: @scientific_name.crop_id || @crop.id }, + = select(:scientific_name, :crop_id, Crop.order(:name).pluck(:name, :id), + { selected: @scientific_name.crop_id || @crop.id }, class: 'form-control') .form-group = f.label :name, class: 'control-label col-md-2'