I''m thinking this is a pretty simple issue, but I''ve been staring at my computer for too long :) I''m simply trying to generate a page that lists items grouped by their "date" attribute like so: 09/25/06 Item1 Item3 09/26/06 Item2 Item4 I''m assuming I would generate some sort of hash in the controller that looks like @things = { "09/25/06" => { Item1, Item3 }, "09/26/06" => { Item2, Item4 } } and then do something like this in the view: <% for $thing in $things %> . . . But I can''t get any further than that. Is this the right direction? If so, how would I generate the hash? Thanks! -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
> <% for $thing in $things %>I meant <% for thing in @things %> , of course -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Matt Rose wrote:> > <% for $thing in $things %> > > I meant <% for thing in @things %> , of course > > -- > Posted via http://www.ruby-forum.com/.try this... groups = @things.group_by {|x| x.date} groups.inspect #=> { ''date1'' => [ array of items with date1], ''date2'' => [array of items with date2] } _Kevin --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---