<% @task_months.sort.each do |month, tasks| %>
<h2><%= month.strftime('%B') %></h2>
<% for task in tasks %>
<div class="task">
<strong><%= task.name %></strong>
due on <%= task.due_at.to_date.to_s(:long) %>
</div>
<% end %>
<hr/> <!-- THIS IS WHAT I NEED TO NOT DISPLAY ON TH LAST RECORD -->
<% end %>
The HR tag above is what I need to not show in the page. I know I could
this easily in a for loop with something like:
<% for task in tasks %>
<%= '<hr/>' unless task == tasks.last %>
...
Anyone have any clue how to do this with an each loop?
Have a look at the rails guide on Debugging and then break in to the
loop and work out what is going on. (use ruby-debug). You can inspect
each variable and see what is not as you expect.
<% @task_months.sort.each do |month, tasks| %>
<h2><%= month.strftime('%B') %></h2>
<% for task in tasks %>
<div class="task">
<strong><%= task.name %></strong>
due on <%= task.due_at.to_date.to_s(:long) %>
</div>
<% end %>
<hr/> <!-- THIS IS WHAT I NEED TO NOT DISPLAY ON TH LAST RECORD -->
<% end %>
In addition to my other suggestion, you might consider using a <table>
element instead of all the <hr>s. Since this is a table of data, the
semantics are more appropriate to the <table> element.
The HR tag above is what I need to not show in the page. I know I could
this easily in a for loop with something like:
<% for task in tasks %>
<%= '<hr/>' unless task == tasks.last %>
...
Anyone have any clue how to do this with an each loop?