Fix undefined method `per' error on Will_Paginate and ActiveAdmin
To get Will_Paginate and ActiveAdmin to play nice and avoid this error:
undefined method `per' for #<ActiveRecord::Relation:0x000000076c9b28>
In your config/initializers, add this:
# config/initializers/kaminari.rb
Kaminari.configure do |config|
config.page_method_name = :per_page_kaminari
end
Source:
https://github.com/gregbell/active_admin/wiki/How-to-work-with-will_paginate
Written by David Chua
Related protips
5 Responses
thank you, works!
over 1 year ago
·
Unfortunately it doesn't work.
No I get the error:
undefined method `per_page_kaminari' for #<ActiveRecord::Relation:0x000000076c9b28>
Any ideas?
over 1 year ago
·
It's not working, I've same problem like @egbertp too. Any idea?
over 1 year ago
·
Just add method per(25) after each "perpagekaminari" call and it should work.
I guess kaminari has some troubles with initialization. After you will added method "per", reload page and remove this "per" method Kaminari started woks fine.
over 1 year ago
·
Finally I found how to fix this issue!!!
add this row after
Kaminari.configure do |config|
....
end
include Kaminari::ActiveRecordModelExtension
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#