Without looking into the problem, I think I would draw 5 tables. Like so:
split_count = @result.size / 5 split_counter = 0
@result.each do |result| <% split_counter++ %>
# make a table and then begin a new table after split_counter has reached split_count.
<% split_counter = 0 if split_counter == split_count %> end
Beware when result.size is < 5 of course.
just from the top of my head, there might very well be a better solution