fixed back/forward
This commit is contained in:
parent
f83b82902c
commit
ca8f136cec
2 changed files with 4 additions and 5 deletions
|
|
@ -69,11 +69,11 @@ class Post < ActiveRecord::Base
|
|||
}
|
||||
|
||||
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
|
||||
|
||||
def self.previous(post)
|
||||
where("posts.created_at < ?", post.created_at)
|
||||
where("posts.created_at < ?", post.created_at).first
|
||||
end
|
||||
|
||||
def post_type
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ class PostPresenter
|
|||
}
|
||||
end
|
||||
|
||||
|
||||
def next_post_url
|
||||
if n = next_post
|
||||
Rails.application.routes.url_helpers.post_path(n)
|
||||
|
|
@ -31,11 +30,11 @@ class PostPresenter
|
|||
end
|
||||
|
||||
def next_post
|
||||
post_base.next(post).first
|
||||
post_base.next(post)
|
||||
end
|
||||
|
||||
def previous_post
|
||||
post_base.previous(post).first
|
||||
post_base.previous(post)
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
|||
Loading…
Reference in a new issue