这是错误:
NoMethodError - undefined method `current_page' for 30:Fixnum:
kaminari (0.15.1) lib/kaminari/helpers/action_view_extension.rb:18:in `paginate'
() home/funkdified/.rvm/gems/ruby-2.1.2@rails4.1/bundler/gems/spree-9d4617334c87/backend/app/views/spree/admin/zones/index.html.erb:13:in `_70ff2f2f2d783197075a15a1a88170b5'
这是有问题的方法
def paginate(scope, options = {}, &block)
paginator = Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :remote => false)
paginator.to_s
end
我不太确定,但这可能与在同一个应用中使用will_paginate有关。我在config / initializers中添加了这段代码:
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
而且,我还尝试添加此内容:
Kaminari.configure do |config|
config.page_method_name = :per_page_kaminari
end
仍然没有运气
答案 0 :(得分:1)
尝试添加
Spree::Product::ActiveRecord_Relation.include Kaminari::PageScopeMethods
to config / initializers / kaminari.rb