ActiveAdmin automatically loading full association table

前端 未结 2 1939
生来不讨喜
生来不讨喜 2021-02-14 18:05

I\'m working on a project that uses ActiveAdmin for its administration backend.

I have two models, a Book model which has_many Products. When I try to access the product

2条回答
  •  南旧
    南旧 (楼主)
    2021-02-14 18:48

    For anyone dealing with this same issue, I finally traced it to the automatically generated sidebar in ActiveAdmin. This includes a search field that includes a select box for all associated records.

    If you have an associated table with over a million records like I do AA will happily attempt to insert the entire table into the select box.

    The answer was to include some custom filters in the AA definition for products like so:

    ActiveAdmin.register Product do
      filter :title
    end
    

    That way the association won't be included (unless you specify it yourself.)

提交回复
热议问题