I have a simple table right now:
OBS Number | <% for week in @week_endings%><%=week.week_ending%> | <%end%>
<%=result%> | <% @results[result].each do |test| %>Date: <%= test[0] %> - Hours: <%= test[1] %> | <%end%>
@week_endings contains dates that are applicable to my @results object
which is a nested hash of ID’s containing dates which have associated
values.
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:
{“25”,{“01-04-2008”,“5.0”},{“01-11-2008”,“10.0”}}
{“30”,{“01-11-2008”,“10.0”}}
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| %>
<%end%>
<%end%>[/code]
I would think I could use my @week_endings object…
So something along the lines of
for result
for week
if result.week == week
else
end
end
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 I can always
elaborate if needed.
Thanks!