diff options
author | Joe Sak <joe@joesak.com> | 2010-11-18 10:52:10 -0600 |
---|---|---|
committer | Joe Sak <joe@joesak.com> | 2010-11-18 10:52:10 -0600 |
commit | dc3cbaa0918c5194ae0f1e80024611c614be612f (patch) | |
tree | 148ec2e27b58295bfbfda2be12863d398d026713 /app/models | |
parent | c610fee93b9e20e083c68d99ee941c6b4f507cf0 (diff) | |
download | refinerycms-blog-dc3cbaa0918c5194ae0f1e80024611c614be612f.tar.gz refinerycms-blog-dc3cbaa0918c5194ae0f1e80024611c614be612f.tar.bz2 refinerycms-blog-dc3cbaa0918c5194ae0f1e80024611c614be612f.zip |
Archive listing, views, helpers
@page added to PostsController
TODO: language file stuff -- I left comments in the view files where these belong. I don't know how to test them from here
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/blog_post.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index 659ef48..562a9b9 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -11,6 +11,20 @@ class BlogPost < ActiveRecord::Base has_friendly_id :title, :use_slug => true default_scope :order => "published_at DESC" + + if Rails.version < '3.0.0' + named_scope :by_archive, lambda { |archive_date| {:conditions => ['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month]} } + else + scope :by_archive, lambda { |archive_date| + where ['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month] + } + end + + if Rails.version < '3.0.0' + named_scope :all_previous, :conditions => ['published_at <= ?', Time.now.beginning_of_month] + else + scope :all_previous, where(['published_at <= ?', Time.now.beginning_of_month]) + end if Rails.version < '3.0.0' named_scope :live, lambda { {:conditions => ["published_at < ? and draft = ?", Time.now, false]} } |