diff options
author | Joe Sak <joe@joesak.com> | 2011-01-10 16:11:53 -0600 |
---|---|---|
committer | Joe Sak <joe@joesak.com> | 2011-01-10 16:11:53 -0600 |
commit | bf74b32f3fbdd50957bdf308b79846eeda7ee1fa (patch) | |
tree | ba836797c939e54c60bf92c30323e2e7c666a8dc /app/models | |
parent | b29b7df9acd67e8d2059766db4a743bc98d3effd (diff) | |
download | refinerycms-blog-bf74b32f3fbdd50957bdf308b79846eeda7ee1fa.tar.gz refinerycms-blog-bf74b32f3fbdd50957bdf308b79846eeda7ee1fa.tar.bz2 refinerycms-blog-bf74b32f3fbdd50957bdf308b79846eeda7ee1fa.zip |
Archives group by year after 2 years
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/blog_post.rb | 4 |
1 files changed, 4 insertions, 0 deletions
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") |