Robert Brown
Robert Brown

Reputation: 11026

Rails ActiveAdmin index formatting numbers

I'd like to have my numbers right aligned and with a thousands separator. Can someone point me in the right direction?

ActiveAdmin.register Thing do
  index do
    column :id
    column :amount  #  need to make this fomatted nicely

    default_actions
 end
end

Upvotes: 6

Views: 3910

Answers (3)

ea0723
ea0723

Reputation: 806

Alternately:

column :amount, :class => 'text-right' do |thing|
  number_to_currency thing.amount
end

then in your CSS

.text-right { text-align: right;}

Upvotes: 5

Scott
Scott

Reputation: 2258

You can pass a block to the column.

column :amount do |thing|
  div :class => "amount" do
    number_to_currency thing.amount
  end
end 

css

.amount {
  text-align :right;
}

This railscast goes through some pretty good info too http://railscasts.com/episodes/284-active-admin?view=asciicast

Upvotes: 13

Related Questions