Comments (10)
Yes this is a good idea. I want to use this gem with https://github.com/davidcelis/api-pagination but it looks like it won't be compatible.
from filterer.
Thanks for the input. As for your use case, you should be able to use the
.chain method:
Line 52 in 9e19f44
On Mon, Dec 22, 2014 at 12:35 AM, Ramon Tayag [email protected]
wrote:
Yes this is a good idea. I want to use this gem with
https://github.com/davidcelis/api-pagination but it looks like it won't
be compatible.—
Reply to this email directly or view it on GitHub
#11 (comment).
Adam Becker
510.928.9111
@AdamJacobBecker
from filterer.
Can the chain
method be used to integrate with kaminari?
I also back this feature request as the filterer
gem - while fantastic for managing filters - is let down by its pagination logic (specifically the view helper).
If it's not possible to integrate kaminari (or will-paginate), I could attempt to improve the pagination logic within this gem.
from filterer.
I believe the following is the appropriate way to integrate kaminari:
# Without Kaminari:
@filterer = PersonFilterer.new(params)
# With Kaminari:
@filterer = PersonFilterer.chain(params).page(params[:page]).per(100)
And the respective change in the view:
# Without Kaminari:
@filterer.results.each do |person|
# With Kaminari:
@filterer.each do |person|
This implementation appears to ignore the sort
configuration in the filterer, however. Is that the reason this issue remains open?
from filterer.
Hey @olliebennett,
Yes, that workaround will work for now. The reason this issue is open is that I'm planning to remove the current pagination methods/views and make usage of kaminari/will_paginate the primary method for pagination.
from filterer.
Great - thanks for the response. Should the 'sort' options be obeyed when using Kaminari in the above manner? In my trials the sort
(and direction
) params are ignored. I believe this is due to the following code in base.rb
:
def find_results
@results = opts.delete(:starting_query) || starting_query
add_params_to_query
return if @opts[:chainable]
order_results
Would it be a problem to move order_results
above the chainable
check? Perhaps (in order to preserve backwards compatibility) we could have a new chain_with_ordering
method or pass a new :include_ordering
option?
If there are no obvious pitfalls with this that you can see, I can attempt to provide a PR for this. Can continue discussion in a separate issue if you prefer? Thanks again
from filterer.
I believe this is due to the following code in base.rb:
Yeah, tbh I don't really remember why the code works that way. I'm 👍 on adding an include_ordering
option until the next major release.
from filterer.
This will be released in 1.0.0.
from filterer.
Great - thanks!
from filterer.
Hi all,
I just pushed 1.0.0.beta.1
to Rubygems. If you have a chance to take a look, maybe read the documentation, and provide some feedback, it would be super helpful!
from filterer.
Related Issues (17)
- don't modify the params hash
- inherit from ActiveModel for form_for compat? HOT 1
- Using filterer without pagination HOT 2
- Add option for removing "limit" altogether HOT 1
- per_page causing error where string is compared to fixnum HOT 1
- Baked in limit / offset? HOT 4
- Allow returning `nil` from param_* method HOT 1
- Rails 5 - to_hash is deprecated HOT 1
- Not using `present_params` HOT 2
- Usage of "chain" and "filter" in Ruby 2.6 HOT 2
- undefined method `filter_without_pagination' for #<ActiveRecord::AssociationRelation []>
- Allow overriding the starting_query HOT 1
- Update badges to shields.io
- ability to assign default params HOT 1
- add method to ActiveRecord::Association? HOT 2
- Add some kind of performance benchmark HOT 1
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 filterer.