Assuming i have a post model with created_at, title, and id. How can i build up an array with years > months > posts to use for the display of archives.
So far i have:
@posts = Post.all(:order => 'created_at DESC')
@post_months = @posts.group_by { |t| t.created_at.beginning_of_month }
This gives me something like {“June 2012” => {“post1”, “post2”}} which is close.
http://shouweick.blogspot.co.uk/2012/02/handling-background-jobs-in-rails-32.html This blog here has the output format i want {year => {november => {post1, post2}, december => {post3}}}
First group by year, and then group those groups by month: