0

I'm using ActiveAdmin (https://github.com/gregbell/active_admin) for Rails, and am trying to load the index view of my User model. Here's the code in my app/admin/users.rb file:

ActiveAdmin.register User do
    config.per_page = 10

    index :pagination_total => false do
    end
end

I have pagination enabled, but it looks like it's still trying to load all of the users, resulting in a timeout. How do I get it to load only a few (e.g. 10) users at a time?

4

1 回答 1

5

您可以尝试提高网页性能的几件事:

  1. 尝试从您可能拥有的任何范围内禁用计数:

    scope :active, show_count: false
    
  2. 尝试禁用不需要的过滤器

    config.filters = false #or simply specify the ones you do need
    
  3. 通过预先加载任何关联模型来避免 n+1 查询

    controller do
      def scoped_collection
        resource_class.includes(:brownies)
      end
    end
    

希望这可以帮助。

于 2013-11-07T01:45:40.410 回答