From bf74b32f3fbdd50957bdf308b79846eeda7ee1fa Mon Sep 17 00:00:00 2001 From: Joe Sak Date: Mon, 10 Jan 2011 16:11:53 -0600 Subject: Archives group by year after 2 years --- app/models/blog_post.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/models') diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index 1887a97..60d982a 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -13,6 +13,10 @@ class BlogPost < ActiveRecord::Base scope :by_archive, lambda { |archive_date| where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month]).order("published_at DESC") } + + scope :by_year, lambda { |archive_year| + where(['published_at between ? and ?', archive_year.beginning_of_year, archive_year.end_of_year]).order("published_at DESC") + } scope :all_previous, where(['published_at <= ?', Time.now.beginning_of_month]).order("published_at DESC") -- cgit v1.2.3