From ff0bd433c5a8d332cc8630cad8732ece57408320 Mon Sep 17 00:00:00 2001 From: Joe Sak Date: Wed, 15 Dec 2010 19:41:08 -0600 Subject: The blog nav should not grab next & previous drafts :) --- app/models/blog_post.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models/blog_post.rb') diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index 1fb9900..1887a97 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -18,8 +18,8 @@ class BlogPost < ActiveRecord::Base scope :live, lambda { where( "published_at < ? and draft = ?", Time.now, false).order("published_at DESC") } - scope :previous, lambda { |i| where(["published_at < ?", i.published_at]).order("published_at DESC").limit(1) } - scope :next, lambda { |i| where(["published_at > ?", i.published_at]).order("published_at ASC").limit(1) } + scope :previous, lambda { |i| where(["published_at < ? and draft = ?", i.published_at, false]).order("published_at DESC").limit(1) } + scope :next, lambda { |i| where(["published_at > ? and draft = ?", i.published_at, false]).order("published_at ASC").limit(1) } def next self.class.next(self).first -- cgit v1.2.3