0

My controller code is

@search = Sunspot.search(Product) do
    fulltext params[:search]
    paginate(page: params[:page], per_page: 1)
  end
  @search_products = @search.results

It gives me an error

undefined method `paginate' for

For pagination I use kaminari gem. It works fine just in case with sunspot it gives an error

Haseeb Ahmad
  • 7,914
  • 12
  • 55
  • 133

1 Answers1

0

Make sure you're ordering the gems correctly in your Gemfile, as order matters for these specific gems:

  gem 'kaminari'
  gem 'sunspot_rails'

Then, you want to paginate on @search:

  <ul>
    <% @search.results.each do |r| %>
    <li><%= r.name %></li>
    <% end %>
  </ul>

  <%= paginate @search %>
Tom Fast
  • 1,138
  • 9
  • 15