ActiveAdmin automatically loading full association table

前端 未结 2 1931
生来不讨喜
生来不讨喜 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:40

    A better approach now is to use remove_filter for the particular attribute or relationship:

    Or you can also remove a filter and still preserve the default filters:

    preserve_default_filters!
    remove_filter :id
    

    https://activeadmin.info/3-index-pages.html

    0 讨论(0)
  • 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.)

    0 讨论(0)
提交回复
热议问题