管理宝石过滤器具有
在我的申请中
产品有许多类别,但category_has_products
类别有许多产品,但category_has_products
最初我用过
在product.rb
default_scope { includes(:brand, :categories) }
并在rails_admin配置中将其设置为
field :categories, :string do
 searchable [{Category => :name}]
end  
这像一个魅力。 由于has_many_through(其他页面使用产品详细信息受到影响),这导致了性能问题。
所以我从产品中删除了default_scope。
之后,我越来越
PG::UndefinedTable: ERROR:  missing FROM-clause entry for table "categories"
有关如何预加载类别的任何想法?
注意:rails_admin gem版本仅为0.8.1我无法更新到最新版本1.XX
我找到答案
在product.rb中
scope :include_categories, -> {includes(:categories)}
class << self
  alias_method :all_products, :include_categories
end  
admin_product_config.rb
from
    scopes %i[all brandless unmatched matched ignored fresh diy_only]
to
    scopes %i[all_products brandless unmatched matched ignored fresh diy_only]
添加过滤器选项
  field :categories, :string do
    searchable [{Category => :name}]
  end      
  configure :categories do
    hide
  end 
谢谢@ jxpx777 https://github.com/sferik/rails_admin/issues/1348#issuecomment-39373394
链接地址: http://www.djcxy.com/p/67067.html