Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide records count from ActiveAdmin scopes

Active Admin lets you define scopes this way :

scope :all
scope :opened
scope :closed

The problem is that it will also display the total record count next to each scope on the index page. This COUNT query can slow down page load a lot when millions of records are involved. ActiveAdmin already lets you hide the total count for the index page this way :

index :pagination_total => false

Is there something similar for scopes? If so, I can't find it!

like image 693
Pierre Olivier Martel Avatar asked Mar 26 '14 15:03

Pierre Olivier Martel


1 Answers

In v0.4.2, a commit was introduced adding a show_count option to scope:
[c12dc45] Adds ability to suppress scope count on a per-scope basis.

The included test (yay testing!) describes this well:

ActiveAdmin.register Post do
  scope :all, default: true, show_count: false
end

I'm not sure how the feature is documented; you might want to propose changes in that regard.

like image 134
Jonathan Allard Avatar answered Nov 13 '22 13:11

Jonathan Allard