Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

stop requiring collection.previous/next_page methods in views

  • Loading branch information...
commit a9b8f07de6e275b531ca2f9c67146f06379f46ff 1 parent 87d0dba
@mislav authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/will_paginate/view_helpers/link_renderer.rb
View
10 lib/will_paginate/view_helpers/link_renderer.rb
@@ -59,11 +59,13 @@ def gap
end
def previous_page
- previous_or_next_page(@collection.previous_page, @options[:previous_label], 'previous_page')
+ num = @collection.current_page > 1 && @collection.current_page - 1
+ previous_or_next_page(num, @options[:previous_label], 'previous_page')
end
def next_page
- previous_or_next_page(@collection.next_page, @options[:next_label], 'next_page')
+ num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
+ previous_or_next_page(num, @options[:next_label], 'next_page')
end
def previous_or_next_page(page, text, classname)
@@ -107,8 +109,8 @@ def tag(name, value, attributes = {})
def rel_value(page)
case page
- when @collection.previous_page; 'prev' + (page == 1 ? ' start' : '')
- when @collection.next_page; 'next'
+ when @collection.current_page - 1; 'prev' + (page == 1 ? ' start' : '')
+ when @collection.current_page + 1; 'next'
when 1; 'start'
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.