Comments (18)
+1
from kaminari.
+1
from kaminari.
+1
from kaminari.
+1 ... Sunspot support would be great.
from kaminari.
Thanks for the request and +1s!
Just added an initial implementation of generic Arrayish object support e04f65a.
Can you bundle '>= 0.12.0' gem and try something like this?
Kaminari.paginate_array(search_result).page(params[:page])
I haven't tested with Sunspot myself, but hope this works.
from kaminari.
I just tested your code:
MyModel.search do
keywords(params[:search])
#paginate(:page => params[:page])
end
Kaminari.paginate_array(result.hits.map(&:result)).page(params[:page])
I works fine, but this way Sunspot can't perform the pagination itself on database level (as far as I see). I would like to leave out the Kaminari::PaginatableArray#page to avoid the offset like this:
MyModel.search do
keywords(params[:search])
paginate(:page => params[:page])
end
Kaminari.paginate_array(result.hits.map(&:result))#.page(params[:page])
Now I am getting the following error:
undefined method
current_page' for #Kaminari::PaginatableArray:0x00000104a47e78`
I am not sure if I am doing something wrong, or if you have to extend Kaminari?
from kaminari.
+1 for sunspot support
from kaminari.
+1
from kaminari.
+1
from kaminari.
Because sunspot handles the pagination I modified the Kaminari paginate helper so it can accept and handle a sunspot search result object. Could someone please test it out in his project before i enter a pull request?
https://github.com/dhiemstra/kaminari/commit/b9e868f737b87d88aa1f81e63a7f71722468f1ce
gem 'kaminari', :git => '[email protected]:dhiemstra/kaminari.git', :branch => :sunspot_support
from kaminari.
I wonder that when Sunspot handles the pagination, why we all vote here for integration?! Wouldn't it be better to clean up this pull request and vote there? Or at least open up a Sunspot ticket?
from kaminari.
Medihack, the reason is that sunspot handles the pagination of the results but not the actual view helper of the pagination.
For example most of the models of our project is normal AR and pagination goes via kaminari, because we have a search function for 3 models we would have to write our own pagination helper next to kaminari's helper or use will_paginate for those results.
This is duplication and forces you to maintain two views for the pagination of your project.
from kaminari.
@dhiemstra, Why do you have to write pagination helpers for each model that has a search? In the view all your doing is passing an array to paginate and as long as the specified methods are defined on it, it just works. That is what medihack is referring to and I agree with.
Anyway, here is a pull request I submitted with tests to sunspot. Can you guys test and report your findings? https://github.com/outoftime/sunspot/pull/63
Thanks.
~Larry
from kaminari.
For anyone looking for a quick and dirty fix until support gets added to sunspot, drop this in config/initializer folder:
https://gist.github.com/1045196
Also, test and +1 to the pull request here:
https://github.com/outoftime/sunspot/pull/64
~Larry
from kaminari.
Thanks lardawge!
from kaminari.
Kaminari support added to Sunspot here: outoftime/sunspot@08dc66b
Please test so we can get a release.
from kaminari.
it works
from kaminari.
It looks like Sunspot has support for generic pagination and there is no additional implementation needed on kaminari-side. Thanks @lardawge for your great work!
Open this issue again if there is any problem with sunspot integration.
from kaminari.
Related Issues (20)
- rails g kaminari:views doesn't generate anything HOT 12
- Hi HOT 1
- undefined local variable or method `paginator' for _page.html.erb:22 partial HOT 2
- Undefined method `without_count' HOT 2
- Update wiki link in GitHub "About" section HOT 1
- issue on method_missing due to separation of positional and keyword arguments in Ruby 3
- Is it possible to add 'data-turbo-action' to the paginate helper? HOT 4
- How to use "Creating Friendly URLs and Caching" in "member do" ?
- With the update from i18n to v1.11.0 `:zero` in not longer supported as key
- Problem Monkey Patching Rails 7.0
- render error for js.erb
- when large table query, use total_count and total_pages slow
- paginate view helper is failing with includes HOT 3
- Updating content_for blocks
- `link_to_first_page` / `link_to_last_page` ?
- inconsistent results in case of LEFT OUTER JOIN, GROUP BY and HAVING HOT 2
- Array doesn't get paginated when total count is passed in HOT 1
- Ambiguous column "id" when PG COUNT is used with certain joins HOT 1
- Pagination links incorrect with Rails 7.1.3 and Kaminari 1.2.2 HOT 8
- using symbol as param_name gives an error in params_for
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kaminari.