Reputation: 15
I am very, very new to rails and slim.
I am trying to create a summary table using
h2 Trading History
table.table-striped.table-bordered#analysis
thead
tbody
- @stock_summary[:stocks].each do |key2, value|
- value.each do |key2, value2|
tr
th = key2
td = value2
Unfortunately, the output is forcing the Data into two columns like so:
name Lennar Corporatio
revenue -7320.0
tax_liability -0.55
capital_at_risk 0.0
returns -1.28
average_holding_period 2.0
capital_invested_percentage 0.0
name General Electric
revenue 2688.89
tax_liability 0.17
capital_at_risk 0.0
returns 2.05
average_holding_period 2.7777777777777777
capital_invested_percentage 0.0
I would like the Summary Table to use the info (name, revenue, tax_liability, capital_at_risk, returns, average_holding_period, capital_invested_percentage) as the 7 Column headers.
Then I would like to populate the table with the info listed to the right.
As per Jason's comment: @stock_summary[:stocks].inspect yields:
{"LEN"=>{:name=>"Lennar Corporatio", :revenue=>-7320.0, :tax_liability=>-0.55,
:capital_at_risk=>0.0, :returns=>-1.28, :average_holding_period=>2.0,
:capital_invested_percentage=>0.0}, "GE"=>{:name=>"General Electric", :revenue=>2688.89,
:tax_liability=>0.17, :capital_at_risk=>0.0, :returns=>2.05,
:average_holding_period=>2.7777777777777777, :capital_invested_percentage=>0.0},
Any help would be greatly appreciated!
-Frank
Upvotes: 1
Views: 3618
Reputation: 11107
How does this work?
table
thead
tr
th Name
th Revenue
th etc.
tbody
- @stock_summary[:stocks].each do |stock, stock_details|
tr
- stock_details.each do |attribute, value|
td = value
Upvotes: 4