Iterating through a collection by date

Is it possible to select all records from a table, then iterate through
the returned objects grouped by a datetime field?

I have a table that has a datetime field called, well, ‘datetime’, and a
string field called (for example’s sake) ‘name’.

What I need to end up with is something along the lines of:

January

<h2>1</h2>

<ul>
  <li>Name 1</li>
  <li>Name 2</li>
</ul>
<h2>2</h2>

<ul>
  <li>Name 3</li>
  <li>Name 4</li>
</ul>

How can I achieve this using Ruby/Rails? I can do it pretty easily
using PHP, but I’m not sure how best to approach it w/ Ruby.

http://weblog.rubyonrails.org/2006/3/1/new-in-rails-enumerable-group_by-and-array-in_groups_of

ed

On 10/27/06, Andrew H. [email protected] wrote:


Ed Hickey
Developer
Litmus Media
816-533-0409
[email protected]
A Member of Think Partnership, Inc
www.ThinkPartnership.com
Amex ticker symbol: THK

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs