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
Post a Comment