How to make sortable column in ActiveAdmin?

342 views Asked by At

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?

1

There are 1 answers

0
DNNX On BEST ANSWER

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.