我在控制器中有一点代码信息:
@today_date = Time.current.to_date.strftime('%Y%m%d')
client = TinyTds::Client.new(:username => 'tr', :password => 'tr', :host => 'xxx.xxx.xxx.xxx', :database => 'KTrade')
data = client.execute("Select symbol, side, orderID, quantity, broker, trader from BBOrders WHERE creationDateTimeInt =" + @today_date)
a =[]
data.each do |row|
a << row
end
@ret = a
视图中的这个块:
<% @ret.each do |row| %>
<div>
<%= row %>
</div>
<% end %>
我得到了这种输出:
{"symbol"=>"Symbol1", "side"=>"BUY ", "orderID"=>"222222", "quantity"=>15, "broker"=>"bankz", "trader"=>"someUser"}
它输出整行。如何单独检索这些值?
答案 0 :(得分:2)
你刚刚放了@ret["symbol"]
等。