I trying to build a table. Here is my HAML code:
%table{:border => 1}
%tbody
%tr
%td Question:
- @cust_dashboard.each do |object|
%tr
%td= object.question
%tr
%td Status:
- @cust_dashboard.each do |object|
%tr
%td= object.status
%tr
%td Created_at:
- @cust_dashboard.each do |object|
%tr
%td= object.created_at
All the items in the table are in one column:
I need a table with three columns:
I haven't written HAML for a while, but I think you want:
%table{:border => 1}
%tbody
%tr
%td Question:
%td Status:
%td Created_at:
- @cust_dashboard.each do |object|
%tr
%td= object.question
%td= object.status
%td= object.created_at
When building your template, think in terms of how the data will be emitted: We'd see:
<table>
<tbody>
<tr>
<td>
<td>
<td>
</tr>
Followed by a series of:
<tr>
<td>
<td>
<td>
</tr>
(indented correctly of course) These would be each data row, three cells across.
I'd probably use th
instead of td
for the headers though:
%th Question:
%th Status:
%th Created_at:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With