Building a "comparisons" table

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?

Hi Paul,

can you give the information of how your @user.run looks like
basically i need the output of @user.run.inspect

Note:
just try using <%= step.start_time.blank? ? “-” : step.start_time %>
instead of <%= step.start_time %>

On Aug 21, 1:53 pm, Paul N. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs