Skip to content

How to work with will_paginate

Drew Ulmer edited this page Jul 17, 2012 · 4 revisions

ActiveAdmin uses Kaminari for pagination and if you use will_paginate in your app, you need to configure an initializer for Kaminari to avoid conflicts. Put this in config/initializers/kaminari.rb

Kaminari.configure do |config|
  config.page_method_name = :per_page_kaminari
end

OR - put this in the same initializer if that doesn't work

if defined?(WillPaginate)
  module WillPaginate
    module ActiveRecord
      module RelationMethods
        def per(value = nil) per_page(value) end
        def total_count() count end
      end
    end
    module CollectionMethods
      alias_method :num_pages, :total_pages
    end
  end
end
Clone this wiki locally