kaminari: Kaminari and will_paginate don't play nice together
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/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
About this issue
- Original URL
- State: open
- Created 13 years ago
- Reactions: 4
- Comments: 21 (3 by maintainers)
One minor fix what I used to make it works
I’ve heard you can fix this by doing something like:
Has anyone tested that this fixes the incompatibility? Waiting on feedback to close this ticket.
Has anyone come up with a solution? Iam using Refinery CMS which uses will_paginate and want to use active admin which uses kaminari.