I have two tables - runs and steps. Each run has many steps, each step
has one run.
The output i’d like:
Description Run1 Run2
Start 13.00 14.35
Run application 13.01 14.48
Process stuff - 14.49
End application 13.05 14.51
Close 13.06 -
Clear down - 14.58
The output i get:
Description Run1 Run2
Start 13.00 14.35
Run application 13.01 14.48
Process stuff 13.05 14.49
End application 13.06 14.51
Close - 14.58
Clear down - -
The problem being some runs don’t share the same steps.
The code in my view is as follows:
Description column (@user just gets the current user’s runs):
<% @user.runs.each_with_index do |run, i| %>
<% if i == 0 %>
<% for step in run.steps %>
<%=h step.description %>
<% end %>
<% end %>
<% end %>
Run columns:
<% for run in @user.runs %>
<% for step in run.steps %>
<%= step.start_time %>
<% end %>
<% end %>
Clearly i need some logic here to arrange the ‘start_time’ data in the
correct row. Can anyone suggest how i can go about this?