How to use ActiveAdmin on models using has_many through association?

前端 未结 6 1283
南笙
南笙 2020-12-12 11:28

I am using ActiveAdmin gem in my project.

I have 2 models using has_many through association. The database schema looks exactly the same as the example in RailsGuide

6条回答
  •  醉话见心
    2020-12-12 12:06

    In answer tomblomfield follow up question in comments:

    Try the following in your AA ActiveAdmin.register Model do block:

      controller do
        def scoped_collection
          YourModel.includes(:add_your_includes_here)
        end
      end
    

    This should lazy load all your associations for each index page in a separate query

    HTH

提交回复
热议问题