Need help figuring out this code block...

Are you trying to output a hash (as text)?

AndyV wrote:

Are you trying to output a hash (as text)?

On Feb 17, 1:04 am, Robert Malko <rails-mailing-l...@andreas-s.net>

I believe so yes, so that way I can get all of the records from the same date into one has so I can iterate through that.

Err... I'm not sure I fully understand what you're trying to accomplish. I'll throw out an idea and maybe that will help.

@projects.inject(activities = ){|activities, project| activities.push project.activities.find(:all, :conditions=>["win_at

= ?", Date.today])}

@current_activities = activities.flatten.group_by{|activity| activity.win_at}.sort

The first line uses a find to make sure that you're dealing with an actual array of activities (rather than an association proxy that looks like one) and the dates you're dealing with lie in the appropriate date range (modify as you need, obviously).

The second line is doing several things. The first line returns an array of arrays, so the call to flatten makes this one big array. Next, group_by iterates over the array and builds a hash, with the hash key being the results of the block; in this case you'll have a key that looks like a nicely formatted date. Finally, the call to sort *should* cause the hash to be recast as an array and then sorted by the keys (dates).

In the end, you should end up with @current_activities being an array sorted in ascending date order. Each entry of @current_activities is an array with the first element being the date and the last element being an array of activities.

Over in your view, you can render this out somehow (not sure how you have your calendar set up) but just as an idea...

... <% @current_activities.each do |activity_set| %>   <h2> <%= activity_set.first.strftime("%B %d, %Y") %></h2>   <ul>   <% activity_set.last.each do |activity| %>     <li> <%= h activity.teaser %> </li>   <% end %>   </ul> <% end %>

HTH, AndyV