When I send a request to a function I get back an array with a nested hashes looking like this (i formatted it a bit for readability):
@variable = [{:"Some ID"=>1, :"Some area"=>"Berlin", :"Company Name"=>"the dummy company", :"A Date"=>2014-01-17 02:15:53 +0100, :"First Name"=>"Michael", :"Last Name"=>"Myers", :"Number Average"=>#<BigDecimal:7fcf546f3da0,'0.5E1',9(18)>, :"Number One"=>5, :"Number Two"=>5, :Comment=>"Tippi Toppi", :Count=>2},
{:"Some ID"=>2, :"Some area"=>"Berlin", :"Company Name"=>"the dummy company", :"A Date"=>2014-01-17 02:15:54 +0100, :"First Name"=>"Michael", :"Last Name"=>"Myers", :"Number Average"=>#<BigDecimal:7fcf546f3bc0,'0.5E1',9(18)>, :"Number One"=>5, :"Number Two"=>5, :Comment=>"OHA", :Count=>2}]
What would I like to do? I want to display the values of the hashes in a table like:
ID | Some Area | Company Name | ...
1 | Berlin | The Dummy company | ...
2 | Berlin | The Dummy company | ...
I have found this answer and tried it, but I get a
undefined method 'data' for #<Hash: ... >.
View
- headers = @variable.map(&:data).flat_map(&:keys).uniq #<< error points here
%tr
- headers.each do |key|
%th= key
- @variable.each do |tr|
%tr
- header.each do |key|
%td= tr.data[key]