# Building a "comparisons" table

**URL:** <https://www.ruby-forum.com/t/building-a-comparisons-table/112607>\
**Category:** Rails\
**Created:** [August 21, 2007, 10:53am UTC](https://www.ruby-forum.com/t/building-a-comparisons-table/112607 "2007-08-21T10:53:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nanouk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/da6949/32.png) [@nanouk](https://www.ruby-forum.com/u/nanouk)\
**Post date:** [August 21, 2007, 10:53am UTC](https://www.ruby-forum.com/t/building-a-comparisons-table/112607/1 "2007-08-21T10:53:55Z")

</div>

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 %\>&nbsp;**  
  
  
\<% 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?

---

<div class="post-metadata">

**Author:** ![nanouk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/da6949/32.png) [@nanouk](https://www.ruby-forum.com/u/nanouk)\
**Post date:** [August 21, 2007, 8:48pm UTC](https://www.ruby-forum.com/t/building-a-comparisons-table/112607/2 "2007-08-21T20:48:39Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
