you are in: codestackercodes [RSS] → tag: will_paginate [RSS]

translating will paginate Delicious Email

show/hide lines
   1  # paste in your environment.rb
   2  
   3  WillPaginate::ViewHelpers.pagination_options[:prev_label]=I18n.t("pagination.prev")
   4  WillPaginate::ViewHelpers.pagination_options[:next_label]=I18n.t("pagination.next")
   5  
   6  # and create the respective translation in your translation file
   7  #    pagination:
   8  #      next: "próximo" 
   9  #      prev: "anterior" 
created by leozera — 14 December 2008 — get a short url — tags: rails ruby will_paginate embed

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