SsPay
SsPay

Reputation: 199

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?

Upvotes: 0

Views: 419

Answers (1)

DNNX
DNNX

Reputation: 6255

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.

Upvotes: 2

Related Questions