Simple solution would be to 'rotate' the information, using an array. Like this (pseudo) code (cannot check if atm)
Controller code:
@stuffs = Stuff.find(:all)
@rotated = []
@rotated[0] = [] # Stuff column0
@rotated[1] = [] # Stuff column1
# etc
index = 0
# Now put the stuff in an array for easy(ier) access
@stuffs.each do |stuff|
@rotated[0][index] = stuff.detail0
@rotated[1][index] = stuff.detail1
index += 1
end
In your View you'd need something like this:
<table>
Table head here!
<% 2.times do |row| %> # Build table (we have 2 stuff details, hence the 2 here)
<tr>
<% index.times do |column| %>
<td><%= @rotated[row][column] %></td>
<% end %>
</tr>
<% end %>
<table>
There are of course better solution, but this seems the most simple/general to me. To rotate some data from some Model.
Like others said with more information we can help you probably much better!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…