fixed back/forward

This commit is contained in:
danielgrippi 2012-02-19 20:05:56 -08:00
parent f83b82902c
commit ca8f136cec
2 changed files with 4 additions and 5 deletions

View file

@ -69,11 +69,11 @@ class Post < ActiveRecord::Base
} }
def self.next(post) def self.next(post)
where("posts.created_at > ?", post.created_at) where("posts.created_at > ?", post.created_at).order('posts.created_at ASC').last
end end
def self.previous(post) def self.previous(post)
where("posts.created_at < ?", post.created_at) where("posts.created_at < ?", post.created_at).first
end end
def post_type def post_type

View file

@ -17,7 +17,6 @@ class PostPresenter
} }
end end
def next_post_url def next_post_url
if n = next_post if n = next_post
Rails.application.routes.url_helpers.post_path(n) Rails.application.routes.url_helpers.post_path(n)
@ -31,11 +30,11 @@ class PostPresenter
end end
def next_post def next_post
post_base.next(post).first post_base.next(post)
end end
def previous_post def previous_post
post_base.previous(post).first post_base.previous(post)
end end
protected protected