如何增加 rails admin gem 中的下拉框限制

How can I increase the limit of drop box in rails admin gem

您好,我遇到了一种情况,无法找到解决方案,有一个保管箱显示与输入的字符串匹配的标签,但限制设置为 30,因为它仅显示 30 个结果。我希望它增加它,但我无法找到应用限制的位置。

日志执行 return 查询,但我找不到它

Started GET "/admin/tag?associated_collection=tags&compact=true&current_action=update&source_abstract_model=video&source_object_id=7732&query=simula" for 127.0.0.1 at 2021-06-10 22:19:57 -0700
Processing by RailsAdmin::MainController#index as JSON
  Parameters: {"associated_collection"=>"tags", "compact"=>"true", "current_action"=>"update", "source_abstract_model"=>"video", "source_object_id"=>"7732", "query"=>"simula", "model_name"=>"tag"}
  Admin Load (0.7ms)  SELECT  `admins`.* FROM `admins` WHERE `admins`.`id` = 14 ORDER BY `admins`.`id` ASC LIMIT 1
  Video Load (0.4ms)  SELECT  `videos`.* FROM `videos` WHERE `videos`.`id` = 7732 ORDER BY `videos`.`id` ASC LIMIT 1
   (0.3ms)  SELECT COUNT(*) FROM `tags`
  Tag Load (1.2ms)  SELECT  `tags`.* FROM `tags` WHERE ((LOWER(tags.name) LIKE '%simula%') OR (LOWER(tags.ui_name) LIKE '%simula%')) ORDER BY tags.id desc LIMIT 30

谁能帮帮我,我怎样才能提高限制

您需要像这样配置字段

rails_admin do
  edit do
    field :tags do
      associated_collection_scope do
        proc do |scope|
          scope.limit(600)
        end
      end
    end
  end
end

但更重要的是,我在 rails_admin 代码上发现了这个搜索,我尝试在 rails admin gem 文件夹中搜索字符串“30”,但没有那么多结果一个有极限。

cd $(bundle show rails_admin)
ag ' 30' | grep limit

这个返回

lib/rails_admin/config/fields/association.rb:43:          associated_collection_scope_limit = (associated_collection_cache_all ? nil : 30)

所以我打开文件,发现具有该范围的代码块是 rails admin 上所有关联字段配置的一部分,所以我知道我可以将它添加到该特定字段。