使用 kaminari 进行太阳黑子分页
我最近决定将我的索引引擎从 sphinx 移植到 solr。在使用 kaminari 和 Thinking_sphinx 后,我决定尝试在 sunspot 中使用通用分页 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
我是使用最新版本的 sunspot,据我所知,这应该使我能够使用 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)
这与我旧的thinking_sphinx 设置完美配合,那么我做错了什么?
I recently decided to port my indexing engine from sphinx to solr. Having used kaminari with thinking_sphinx I decided to try making use of generic pagination in sunspot https://github.com/sunspot/sunspot/pull/64 / https://github.com/sunspot/sunspot/pull/67, in order to use avoid moving to will_paginate.
My search is handled as follows:
@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
My view is unchanged from what I had when I was using thinking_sphinx:
<%= render :partial => 'address' %>
<%= paginate @addresses %>
My problem is that after the change I continually get the following error when trying to perform a search:
undefined method `current_page' for []:Array
I am using the latest version of sunspot, which to my knowledge should enable me to use 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)
This worked perfectly with my old thinking_sphinx setup, so what am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我使用的方式,效果很好
,在视图中我有这个
This is how I have used and it works great
And in views I have this