簡體   English   中英

Kaminari分頁錯誤

[英]Kaminari pagination error in spree

這是錯誤:

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

還是沒有運氣

嘗試添加

Spree::Product::ActiveRecord_Relation.include Kaminari::PageScopeMethods

配置/初始化/ kaminari.rb

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM