ruby-on-railsrubyactiveadminmoney-rails

How to make sortable column in ActiveAdmin?


I have column on index page in ActiveAdmin:

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

I'm using gem money-rails for :credit_amount and .format method on index page for readability.

But sorting doesn't work. How can I make sorting from largest to smallest and vice versa for this column?


Solution

  • Try this

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

    Just make sure to replace products with whatever table name you have.