Led
Led

Reputation: 615

Active admin filter time display

in one of my index in active admin i have a time-start field i used a :time for database format which is currently(2012-04-05 16:59:00.000000) inside my database, so my index is showing (January 01, 2000 02:02) i want only the time to be show my index do is

index do 
    column "Guest Name", :name
    column "Service Type", :service
    column "Booked Date", :date
    column "Time Start", :timeStart
    column "Time End",:timeEnd
    column "Number of guest", :numGuest
    default_actions
  end

im think to do this but obviously it will not work

column "Time Start", :timeStart.strftime('%H:%M:%S:%p')

much appreciated for the help thank you in advance more power to all

Upvotes: 1

Views: 977

Answers (2)

yorch
yorch

Reputation: 7318

Something like this should do it:

index do
  column :timeStart, :sortable => :timeStart do |r|
    r.timeStart.strftime('%H:%M:%S:%p')
  end
end

To not loose the sort ability on that column, you can use the :sortable on the column

Upvotes: 3

Acek
Acek

Reputation: 133

You can use a block for this:

index do |model|
    column "Time Start" do
        model.timeStart.strftime('%H:%M:%S:%p')
    end
end

Upvotes: 1

Related Questions