Add class method to find uncategorized posts
This commit is contained in:
parent
3ecdeae3b0
commit
f520d6c6e7
1 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue