Я пытался создать собственный CSV в активном администраторе для модели Saloon, и у меня есть один столбец с массивом OperationalHours.
Вот мой объект:
[20] pry(main)> Saloon.first
=> #<Saloon:0x00007fa773496cf0
id: 1,
address_1: "1313 2nd St South",
city: "Battlefield",
state: "Missouri",
zip: "63303",
operational_hours:
[#<OperationalHours:0x00007fa77aa72848 @closing_time="5:00 PM", @notes="", @opening_time="9:00 AM">,
#<OperationalHours:0x00007fa77aa725f0 @closing_time="5:00 PM", @notes="", @opening_time="9:00 AM">,
#<OperationalHours:0x00007fa77aa723c0 @closing_time="5:00 PM", @notes="", @opening_time="9:00 AM">,
#<OperationalHours:0x00007fa77aa72190 @closing_time="Closed", @notes="", @opening_time="Closed">,
#<OperationalHours:0x00007fa77aa71f10 @closing_time="Closed", @notes="", @opening_time="Closed">,
#<OperationalHours:0x00007fa77aa71ce0 @closing_time="Closed", @notes="", @opening_time="Closed">,
#<OperationalHours:0x00007fa77aa71ab0 @closing_time="Closed", @notes="", @opening_time="Closed">],
name: "Clear Cut",
trial_period: 30,
time_zone: "Central Time (US & Canada)">
И в у меня есть активный админ-файл:
ActiveAdmin.register Saloon do
csv do
column :name
column "Operation Hours" do |sal|
sal.operational_hours.each do |hour|
"#{hour.opening_time}-#{hour.closing_time}"
end
end
end
end
Но часы работы в CVS:
[#<OperationalHours:0x00007fcf295e2a90 @opening_time="9:00 AM", @closing_time="5:00 PM", @notes="">,
#<OperationalHours:0x00007fcf295e2798 @opening_time="9:00 AM", @closing_time="5:00 PM", @notes="">,
#<OperationalHours:0x00007fcf295e2428 @opening_time="9:00 AM", @closing_time="5:00 PM", @notes="">,
#<OperationalHours:0x00007fcf295e2158 @opening_time="9:00 AM", @closing_time="5:00 PM", @notes="">,
#<OperationalHours:0x00007fcf295e1eb0 @opening_time="9:00 AM", @closing_time="5:00 PM", @notes="">,
#<OperationalHours:0x00007fcf295e1910 @opening_time="9:00 AM", @closing_time="5:00 PM", @notes="">,
#<OperationalHours:0x00007fcf295e1690 @opening_time="9:00 AM", @closing_time="5:00 PM", @notes="">]
Есть ли способ перебирать часы работы и показывать каждое из них как "9:00 AM" -5: 00 вечера "формат?