will_paginate snippets

Will Paginate pagination helper

Tagged pagination, will_paginate, helper  Languages ruby
module ApplicationHelper
  def paginate(collection)
    if collection.previous_page && !collection.next_page
      will_paginate collection, :page_links => true, :next_label => "", :prev_label => "« Previous"
    elsif collection.next_page && !collection.previous_page
      will_paginate collection, :page_links => true, :next_label => "Next »", :prev_label => ""
    else
      will_paginate collection, :page_links => true, :next_label => "Next »", :prev_label => "« Previous"
    end
  end
end

How to use WillPaginate with Sinatra

Tagged pagination, sinatra, will_paginate  Languages ruby
require 'will_paginate'
require 'will_paginate/active_record'
require 'will_paginate/view_helpers/sinatra'

class App < Sinatra::Base
  helpers WillPaginate::Sinatra::Helpers

  helpers do
    def paginate(collection)
       options = {
         #renderer: BootstrapPagination::Sinatra,
         inner_window: 0,
         outer_window: 0,
         previous_label: '&laquo;',
         next_label: '&raquo;'
       }
      will_paginate collection, options
    end
  end
end

Also see will_paginate-bootstrap.