Skip to content

Instantly share code, notes, and snippets.

@ryantinker
Created December 20, 2013 18:57
Show Gist options
  • Save ryantinker/8059628 to your computer and use it in GitHub Desktop.
Save ryantinker/8059628 to your computer and use it in GitHub Desktop.
Print the output of a SQL query in a table.
<table border=1>
<tr>
<% @sql_results.first.keys.each do | key | %>
<th>
<%= key %>
</th>
<% end %>
</tr>
<% @sql_results.each do | result | %>
<tr>
<% result.values.each do | value | %>
<td><%= value %></td>
<% end %>
</tr>
<% end %>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment