From 5b21720ac0787cc8f39e5713a29ad77db84f19c1 Mon Sep 17 00:00:00 2001 From: Thiago Youssef <43591948+thiagoyoussef@users.noreply.github.com> Date: Thu, 14 Nov 2024 07:30:31 -0300 Subject: [PATCH] avoid count query --- app/controllers/avo/associations_controller.rb | 2 +- lib/avo/fields/belongs_to_field.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/avo/associations_controller.rb b/app/controllers/avo/associations_controller.rb index 611219eab..d25de5978 100644 --- a/app/controllers/avo/associations_controller.rb +++ b/app/controllers/avo/associations_controller.rb @@ -278,7 +278,7 @@ def select_options(query) query.all.limit(Avo.configuration.associations_query_limit).map do |record| [@attachment_resource.new(record: record).record_title, record.to_param] end.tap do |options| - options << t("avo.more_records_available") if query.all.count > Avo.configuration.associations_query_limit + options << t("avo.more_records_available") if options.count == Avo.configuration.associations_query_limit end end end diff --git a/lib/avo/fields/belongs_to_field.rb b/lib/avo/fields/belongs_to_field.rb index 7b93a94d1..7bc73c959 100644 --- a/lib/avo/fields/belongs_to_field.rb +++ b/lib/avo/fields/belongs_to_field.rb @@ -129,7 +129,7 @@ def values_for_type(model = nil) query.all.limit(Avo.configuration.associations_query_limit).map do |record| [resource.new(record: record).record_title, record.to_param] end.tap do |options| - options << t("avo.more_records_available") if query.all.count > Avo.configuration.associations_query_limit + options << t("avo.more_records_available") if options.count == Avo.configuration.associations_query_limit end end