I needed to group records by year. From this post and the enumerate module docs we end up with
entries = Entry.find :all, :order => 'date DESC'The group_by returns a hash with keys corresponding to the result of the block (i.e. the year)
entries.group_by do |entry|
entry.date.year
end
Comments
Post a Comment