I am attempting to integrate my website(runs with RoR) with algolia search service. can anyone help me how to paginate results(hits) with kaminari gem? Thanks in advance.
Asked
Active
Viewed 277 times
1 Answers
0
The project README has just been updated with some backend pagination examples:
Even if Algolia highly recommends to perform all search (and therefore pagination) operations from your frontend using JavaScript, the gem supports both will_paginate and kaminari as pagination backend.
To use :will_paginate
, specify the :pagination_backend
as follow:
AlgoliaSearch.configuration = { application_id: 'YourApplicationID', api_key: 'YourAPIKey', pagination_backend: :will_paginate }
Then, as soon as you use the search
method, the returning results will be a paginated set:
# in your controller
@results = MyModel.search('foo', hitsPerPage: 10)
# in your views
## if using will_paginate
<%= will_paginate @results %>
## if using kaminari
<%= paginate @results %>

redox
- 2,269
- 13
- 22