views:

442

answers:

2

I'm trying to evaluate Ruport for use in my Rails app, but am not sure how to take a series of records with date/time stamps and group them via Ruport's grouping functions.

I'm open to other/better methods to do this same grouping if Ruport doesn't make sense.

+2  A: 

Without ruport:

<% @posts.group_by {|p| p.created_at.at_beginning_of_day }.each do |day, posts| %>
  <h2><%= day.strftime("something...") %></h2>

  <% posts.each do |post| %>
    do stuff with `post`.
  <% end %>
<% end %>

Use at_beginning_of_month, at_beginning_of_week and so on, depending on what you want to group by.

August Lilleaas
This helped me to much right now. Thanks! I wish I could upvote it a few more times.
Joost Schuur
+1  A: 

I would suggest moving the @posts.group_by function into the controller rather than the view.

mike_wags