简体   繁体   中英

Load timeout in Rails's Active Admin

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 (eg 10) users at a time?

A few things you could try to improve performance on your pages:

  1. Try disabling the count from any scopes you might have:

     scope :active, show_count: false 
  2. Try disabling filters you don't need

     config.filters = false #or simply specify the ones you do need 
  3. Avoid n+1 queries by eager loading any associated models

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

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM