#162·kaminari

Kaminari and will_paginate don't play nice together

Author: wakelessCreated Sep 8, 2011Updated Feb 3, 2026
LabelsActiveRecord

There's an issue when kaminari and will_paginate are loaded into the same project together.

It stems from where kaminari loads it's Relation methods in scope :page whereas will_paginate defines a page method.

https://github.com/amatsuda/kaminari/blob/master/lib/kaminari/models/active_record_model_extension.rb#L12-L17

https://github.com/mislav/will_paginate/blob/master/lib/will_paginate/active_record.rb#L130-L139

This means that will_paginate runs roughshod over the scope and the Relation stuff never gets loaded. As you can see in the 2 patches they pretty much both do the same thing (set limit and offset).

I've kinda fixed the issue by

::ActiveRecord::Relation.send :include, Kaminari::ActiveRecordRelationMethods
::ActiveRecord::Relation.send :include, Kaminari::PageScopeMethods

in https://github.com/amatsuda/kaminari/blob/master/lib/kaminari/railtie.rb#L18 but it's nowhere near as elegant as the previous solution. forcing the inclusing of Kaminari::ActiveModel