I'm trying to find a way to display an array in a Rails view as follows:
[ 1 ] [ 4 ] [ 7 ] [ 10 ]
[ 2 ] [ 5 ] [ 8 ] [ 11 ]
[ 3 ] [ 6 ] [ 9 ] [ 12 ]
In my controller, I have an array defined as
def index
@myArr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
end
Since this display order is not typical for a table, I am unsure how to proceed to accomplishing this.
I would like to know the following:
What's the best way to display the values (above) in a table on my Rails view page using the order that I have requested in the code? Simply looping over the
@myArr
with<tr>
and<td>
results in the following:[ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ]
Thanks in advance for your help!