Kaminari problems while upgrading to Rails 5

386 Views Asked by At

We are upgrading a rails app from v3 to v5 and are using ActiveAdmin which has a dependency on Kaminari. In this process we had to change all our models to inherit from ApplicationRecord instead of ActiveRecord::Base. This change results in the following errors:

undefined method `per_page_kaminari' for #Team::ActiveRecord_Relation:0x00555f215eb200

where Team is a model that was previously inheriting from ActiveRecord::Base and was changed to inherit from ApplicationRecord. Any help to fix this would be much appreciated.

2

There are 2 best solutions below

0
On BEST ANSWER

I have resolved this issue by placing the following code at the bottom of the application.rb file.

class Application < Rails::Application

    ...

    # Initialize Kaminari before the appropriate models loading.
    Kaminari.configure do |config|
      config.page_method_name = :per_page_kaminari
    end
end
0
On

The Same problem was facing by me as well

It's because of the conflicts on the will paginate and kaminari

Add the file in initializers/ folder

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