To edit pages or tickets please login with username/password: aaf/aaf

Ticket #216: search_results_new_will_paginate_interface.diff

File search_results_new_will_paginate_interface.diff, 1.3 kB (added by aaf, 5 months ago)
  • lib/search_results.rb

    old new  
    44  # paging support to search result arrays 
    55  class SearchResults < ActsAsFerret::BlankSlate 
    66    reveal :methods 
    7     attr_reader :current_page, :per_page, :total_hits 
     7    attr_reader :current_page, :per_page, :total_hits, :total_pages 
    88    alias total_entries total_hits  # will_paginate compatibility 
     9    alias page_count total_pages    # will_paginate backwards compatibility 
    910 
    1011    def initialize(results, total_hits, current_page = 1, per_page = nil) 
    1112      @results = results 
     
    2627 
    2728    # code from here on was directly taken from will_paginate's collection.rb 
    2829 
    29     # 
    30     # The total number of pages. 
    31     def page_count 
    32       @total_pages 
    33     end 
    34  
    3530    # Current offset of the paginated collection. If we're on the first page, 
    3631    # it is always 0. If we're on the 2nd page and there are 30 entries per page, 
    3732    # the offset is 30. This property is useful if you want to render ordinals 
     
    4843 
    4944    # current_page + 1 or nil if there is no next page 
    5045    def next_page 
    51       current_page < page_count ? (current_page + 1) : nil 
     46      current_page < total_pages ? (current_page + 1) : nil 
    5247    end 
    5348  end 
    5449 

To edit pages or tickets please login with username/password: aaf/aaf