On 9 October 2010 13:09, Michael Pavling <[email protected]> wrote: > On 8 October 2010 22:30, Leonel *.* <[email protected]> wrote: >> <% current_date = Date.today %> >> >> <% if current_date == appointment.start.strftime("%Y-%m-%d") %> > > Aside from comparing Date with String, which is *never* going to return > true... > >> <% @appointments.each do |appointment| %> > > Why not use the .group_by to sort all the appointments by startdate, > and then iterate each element of the ordered hash that sort_by > returns? > > <% @appointments.group_by{ |appointment| > appointment.start.strftime("%Y-%m-%d") }.each_pair do |start_date, > appointments| %>
I think there are a couple of problems with that, firstly I think there is something missing as you have not specified which field to group by. Secondly the OP does not say but I imagine that the the start time contains a time of day value so it will be necessary to group just on the day part of start. Colin -- 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.

