aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/blog_post.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/blog_post.rb')
-rw-r--r--app/models/blog_post.rb14
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]} }