Iterating through hash to line up dates correctly in a table

I have a simple table right now:

<% for week in @week_endings%> <%end%> <% @results[result].each do |test| %> <%end%> <%end%>
OBS Number<%=week.week_ending%>
<%=result%>Date: <%= test[0] %> - Hours: <%= test[1] %>

@week_endings contains dates that are applicable to my @results object
which is a nested hash of ID’s containing dates which have associated

After I setup my header which would look like:
OBS Number 01-04-2008 01-11-2008

I would like to iterate through my hash and where the data applicable,
place it in the table in the column containing the date it pertains to.

So a row would look like the following with the hash:

OBS Number 01-04-2008 01-11-2008
25 5.0 10.0
30 0.0 10.0

Where I’m building my rows using my hash with the following:
<[email protected] do |result| %>

<% @results[result].each do |test| %>
Date: <%= test[0] %> - Hours: <%= test[1] %>

I would think I could use my @week_endings object…

So something along the lines of
for result
for week
if result.week == week


An value for a day for given ID may not exist. So if could have a value
for the 11th but not the 4th so I need to skip by the 4th by putting a 0
in the field and move on to the 11th and insert that value.

But when I tried to code that my values weren’t printing correctly.

Any thoughts would be appreciated, sorry if this comes off as confusing,
I tried to make it sound as simple as possible :slight_smile: I can always
elaborate if needed.


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