I'm trying to build a table of JSON data in a custom page in Active Admin. The JSON response is fairly deeply nested so I'm using a lot of loops. Here's as far as I've been able to get/some of what I've tried:
panel "Boxes" do
boxes.each do |box| #isolate each hash item in the array
# table_for box.values do
box.each do |key, value|
if value.is_a?(Hash) #if value of a hash is a hash
columns do
value.each do |k, v| #iterate through the hash
text_node "#{k}: #{v}"
end
end
elsif value.is_a?(Array) #there's only one value that's an array & the key is "Products"
columns do
value.each do |products_array|
columns do
products_array.each do |k, v|
if v.is_a?(Hash)
v.each do |kk, vv|
if vv.is_a?(Hash)
vv.each do |kkk, vvv|
text_node "#{kkk}: #{vvv}, "
end
else
text_node "#{kk}: #{vv}, "
end
end
else
text_node "#{k}: #{v}, "
end
end
end
end
end
else
# key.each do
# column key
# end
end
end
# end
end
I'm looking for general guidelines as to how to make a table in a custom Active Admin page as well as how to access/display deeply nested array/hash attributes. Thanks!