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?
This is how I have used and it works great
@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
And in views I have this
<%= paginate @search.hits %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With