我对rails和slim很陌生。
我正在尝试使用
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
不幸的是,输出将数据强制分为两列,如下所示:
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
我希望汇总表使用信息(姓名、收入、纳税义务、风险资本、回报、平均持有期、资本投资百分比)作为7列标题。
然后我想用右边列出的信息填充表。
根据杰森的评论:
@股票摘要[股票]。检查收益率:
{"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},
任何帮助都将不胜感激!
-弗兰克
最佳答案
这是怎么工作的?
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
关于html - 设置表头并填充数据; Rails和SLIM,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18985682/