Ok, after some thinking and experimentation, I came up with:

<% posts = Post.all(:select => "year, month", :order => "year, 
month").collect(&:attributes) %>
<% (posts.first["year"]..posts.last["year"]).to_a.reverse.each do |year| 
%>
  <p><%= year %></p>
  <% posts_by_year = posts.select{|hash| hash["year"] == year} %>
  <ul class="nostyle">
    <% (1..12).to_a.reverse.each do |index| %>
      <% posts_by_month = posts_by_year.select{|hash| hash["month"] == 
("%02d" % index)}%>
      <% unless posts_by_month.length == 0 %>
        <li><%= link_to "#{Date::MONTHNAMES[index]} #{year}", 
month_path(year, ("%02d" % index)) %> (<%= posts_by_month.length 
%>)</li>
      <% end %>
    <% end %>
  </ul>
<% end %>

It's working well. It's all still stuck in the view, but oh well. If 
anyone knows a better place, let me know.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to