Add class method to find uncategorized posts

This commit is contained in:
Joe Sak 2011-02-16 00:12:40 -06:00
parent 3ecdeae3b0
commit f520d6c6e7

View file

@ -26,7 +26,7 @@ class BlogPost < ActiveRecord::Base
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
end
@ -51,6 +51,10 @@ class BlogPost < ActiveRecord::Base
:scoping => 'blog'
})
end
def uncategorized
posts = BlogPost.live.reject { |p| p.categories.any? }
end
end
module ShareThis