Topic: grouping by year

hi,

my model :
class something
  has_many :events, :order => 'date ASC'

In my view, I try to make something like this :
2013
-- Event1 : description
-- Event3 : description
2012
--Event2 : description
--Event5 : description

In my view:
      <% for ev_ent in @events %>
<h3><%= ev_ent.date.strftime("%Y") %></h3>
    -- <%= l( ev_ent.date) %>-<%= ev_ent.titre %> : <%= ev_ent.description %>
etc

so i need to "group" my date per year.

In my controler, i try :
@events= @guitariste.events.group("date")
or
@events= @guitariste.events.group( 'date'.strftime("%Y")
or
select_year.......

Someone can help me please ??
best regards

Last edited by pasqal (2013-02-28 18:16:25)