Skip to content

Instantly share code, notes, and snippets.

@firedev
Created May 23, 2013 05:53
Show Gist options
  • Save firedev/5632994 to your computer and use it in GitHub Desktop.
Save firedev/5632994 to your computer and use it in GitHub Desktop.
Fix for Kaminari strange window implementation. Works with Kaminari 0.13
# Fixes https://github.com/amatsuda/kaminari/issues/133
# put into /initializers/kaminari.rb
module Kaminari
module Helpers
class Paginator < Tag
class PageProxy
def inside_window?
if @options[:current_page] <= @options[:window]
@page <= (@options[:window] * 2) + 1
elsif (@options[:num_pages] - @options[:current_page].number) < @options[:window]
@page >= (@options[:num_pages] - (@options[:window] * 2))
else
(@options[:current_page] - @page).abs <= @options[:window]
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment