【问题标题】:How to make sortable column in ActiveAdmin?如何在 ActiveAdmin 中制作可排序的列?
【发布时间】:2020-11-12 13:25:59
【问题描述】:

我在 ActiveAdmin 的索引页上有列:

column("Credit amount", sortable: true) {|u| u.credit_amount.format }

为了便于阅读,我在索引页上使用 gem money-rails 表示 :credit_amount.format 方法。

但是排序不起作用。 我怎样才能让这个列从大到小排序,反之亦然?

【问题讨论】:

    标签: ruby-on-rails ruby activeadmin money-rails


    【解决方案1】:

    试试这个

    column("Credit amount", sortable: 'products.credit_amount_cents') {|u| u.credit_amount.format }
    

    只需确保将 products 替换为您拥有的任何表名即可。

    【讨论】:

      猜你喜欢
      • 2012-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-30
      相关资源
      最近更新 更多