sql - Best way to join unique month and year from db in rails 3 ( or otherwise ) -


i trying figure out nice way of doing , thought maybe there nicer way in newer rails 3.0 activerecord query.

i have bunch of posts have published_at field.

now want present archive in sidebar unique months , year contains posts , display archive. what's best way avoiding heavy hits on db on every pageload? suggestions?

you need query along lines of select distinct date_format(published_at, '%m %y'), count(id) posts group 1. it's trivial matter convert ar syntax.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -