【问题标题】:Hide records count from ActiveAdmin scopes从 ActiveAdmin 范围隐藏记录计数
【发布时间】:2014-03-26 15:50:31
【问题描述】:

Active Admin 允许您以这种方式定义范围:

scope :all
scope :opened
scope :closed

问题在于它还会在索引页面上的每个范围旁边显示总记录数。当涉及数百万条记录时,此 COUNT 查询会大大降低页面加载速度。 ActiveAdmin 已经允许您以这种方式隐藏索引页面的总数:

index :pagination_total => false

范围有类似的东西吗?如果是这样,我找不到它!

【问题讨论】:

    标签: ruby-on-rails activeadmin


    【解决方案1】:

    在 v0.4.2 中,引入了一个提交,将 show_count 选项添加到 scope:
    [c12dc45] Adds ability to suppress scope count on a per-scope basis

    包含的测试(耶测试!)很好地描述了这一点:

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

    我不确定该功能是如何记录的;您可能想在这方面提出更改建议。

    【讨论】:

    • 有没有办法让这个切换功能?像show_count: params[:show_count]一样,我不能在这个部分添加params对吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-02
    • 2021-10-20
    • 2013-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多