Frage

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!

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top