如果您使用的是mysql2 gem,那么您应该获取mysql2结果对象,并且根据文档,您应该能够执行以下操作
results.each do |row| # conveniently, row is a hash # the keys are the fields, as you'd expect # the values are pre-built ruby primitives mapped from their corresponding field types in MySQL # Here's an otter: http://farm1.static.flickr.com/130/398077070_b8795d0ef3_b.jpgend
在此处查阅文档
因此,在这种情况下,您可以执行以下操作
<% @results.each do |val| %> <%= "#{val['id']}, #{val['name']}, #{val['age']}" %><% end %>编辑 :您似乎是指错误的文档,请检查Mysql2 gems文档。



