you are in: codestackercodes [RSS]record count and current records using will_paginate

record count and current records using will_paginate Delicious Email

returns “Displaying records 1 – 10 of 35”. used in codestacker

show/hide lines
   1  # 1) model:
   2  
   3    def self.per_page
   4      10
   5    end
   6  
   7  # 2) helper:
   8  
   9    def paginate_range(in_collection, in_tot_count)
  10      endnumber = in_collection.offset + in_collection.per_page > in_tot_count ? 
  11        in_tot_count : in_collection.offset + in_collection.per_page
  12      "Displaying records #{in_collection.offset + 1} - #{endnumber} of #{in_tot_count}"
  13    end
  14  
  15  # 3) controller 
  16  
  17      @codes = Code.paginate :conditions => conditions, :page => params[:page]
  18      @codes_count = Code.count
  19  
  20  # 4) view: 
  21  
  22  <%= paginate_range @codes, @codes_count %>
created by leozera — 22 October 2008 — get a short url — tags: ruby will_paginate embed

Comments



We dont send spam :)

If checked, it's highlights your comment
simple_captcha.jpg
Are you a human? Type the code from the image