aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2012-02-23 00:20:37 -0800
committerPete Higgins <pete@peterhiggins.org>2012-02-23 00:20:37 -0800
commit5eaad8997fa5d8e63f331ec5846f029506a6e309 (patch)
treec90bc079533b02d66ad920e3a482a3a22c194d08 /app/models
parent2537923034163a3a99810bde11cdee95339d60b5 (diff)
downloadrefinerycms-blog-5eaad8997fa5d8e63f331ec5846f029506a6e309.tar.gz
refinerycms-blog-5eaad8997fa5d8e63f331ec5846f029506a6e309.tar.bz2
refinerycms-blog-5eaad8997fa5d8e63f331ec5846f029506a6e309.zip
Cleanup next and previous stuff.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/refinery/blog/post.rb11
1 files changed, 4 insertions, 7 deletions
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb
index 81d2f54..6873243 100644
--- a/app/models/refinery/blog/post.rb
+++ b/app/models/refinery/blog/post.rb
@@ -8,7 +8,6 @@ module Refinery
is_seo_meta if self.table_exists?
default_scope :order => 'published_at DESC'
- #.first & .last will be reversed -- consider a with_exclusive_scope on these?
belongs_to :author, :class_name => 'Refinery::User', :foreign_key => :user_id, :readonly => true
@@ -41,11 +40,11 @@ module Refinery
self.per_page = Refinery::Blog.posts_per_page
def next
- self.class.next(self).first
+ self.class.next(self)
end
def prev
- self.class.previous(self).first
+ self.class.previous(self)
end
def live?
@@ -78,7 +77,7 @@ module Refinery
end
def previous(item)
- published_before(item.published_at).limit(1)
+ published_before(item.published_at).first
end
def uncategorized
@@ -86,9 +85,7 @@ module Refinery
end
def next(current_record)
- self.send(:with_exclusive_scope) do
- where(["published_at > ? and draft = ?", current_record.published_at, false]).order("published_at ASC")
- end
+ where(["published_at > ? and draft = ?", current_record.published_at, false]).first
end
def published_before(date=Time.now)