ruby-on-rails – 太阳黑子与kaminari分页

我最近决定将我的索引引擎从sphinx移植到solr.使用kaminari和thinking_sphinx后,我决定尝试在太阳黑子 https://github.com/sunspot/sunspot/pull/64/ https://github.com/sunspot/sunspot/pull/67中使用泛型分页,以避免移动到will_paginate.

我的搜索处理如下:

@search = Address.search do
  fulltext params[:search]
  with(:updated_at).greater_than(1.week.ago)
  order_by :updated_at,:desc
  paginate :page => params[:page],:per_page => 7
end

我的观点与使用thinking_sphinx时的观点没有变化:

<%= render :partial => 'address' %>
<%= paginate @addresses %>

我的问题是,在更改后,我在尝试执行搜索时不断收到以下错误:

undefined method `current_page' for []:Array

我正在使用最新版本的太阳黑子,据我所知应该让我使用kaminari:

Using sunspot (1.3.0.rc3) from git://github.com/sunspot/sunspot.git (at master) 
Using sunspot_rails (1.3.0.rc3) from git://github.com/sunspot/sunspot.git (at master)

这与我的旧think_sphinx设置完美配合,所以我做错了什么?

解决方法

这就是我使用的方式,效果很好
@search = Sunspot.search(Listing) do
      if params[:category].present?
        with :category_id,params[:category]
      end
      if params[:subcategory].present?
        with :subcategory_id,params[:subcategory]
      end
      if params[:q].present?
        keywords params[:q]  do 
          fields :title,:description
        end
      end
      paginate :page => params[:page],:per_page => SEARCH_RESULT_PER_PAGE
    end

在观点中,我有这个

<%= paginate @search.hits %>

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...