管理面板上的rails_admin gem 和 will_paginate-bootstrap gem 的 #<Customer::ActiveRecord_Relation:0x007f6ef6d11b60> 的未定义方法“per”

nee*_*yes 3 will-paginate rails-admin ruby-on-rails-5

我为管理面板安装了“rails_admin”gem。我已经安装了 'will_paginate-bootstrap' gem。 在此输入图像描述


当我单击型号名称时,出现此错误 在此输入图像描述

ros*_*nd 5

在 app/config/initializers 中创建 kaminari.rb 并且,

Kaminari.configure do |config|
  config.page_method_name = :per_page_kaminari
end
Run Code Online (Sandbox Code Playgroud)

当您启用 will_paginate 时,请在初始化程序中创建 will_paginate.rb ,并且,

if defined?(WillPaginate)
  module WillPaginate
    module ActiveRecord
      module RelationMethods
        def per(value = nil) per_page(value) end
        def total_count() count end
        def first_page?() self == first end
        def last_page?() self == last end
      end
    end
    module CollectionMethods
      alias_method :num_pages, :total_pages
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

这应该适用于有 will_paginate 的rails_admin