Skip to content

[WIP] Make paginator definition explicit #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

eidge
Copy link
Contributor

@eidge eidge commented Jan 28, 2015

There are cases when both will_paginate and kaminari will be in your dependencies, even though you're only using one of them. In our case we're using will_paginate and activeadmin (which internally uses kaminari for pagination).

I've modified the way ApiPagination initializes to allow explicit paginator definition. It works like this:

initializers/api_pagination.rb

ApiPagination.config do |options|
  options.paginator = :will_paginate
end

This way you can have both kaminari and will_paginate defined and still be able you use this gem for api pagination.

You do loose the ability to just include the gem in the gemfile and be done with it (now you also need to define an initializer).

It should be possible to have both, what do you think about this workflow?

@davidcelis
Copy link
Owner

I do think it's possible to have both and, actually, I have a solution in my head that could take care of it. I could just go ahead and commit it for you, but I've totally been annoyed in the past when I submit a patch to a project and the maintainer just ends up writing their own instead. I'm willing to work with you on your patch but to be honest, I've wanted to see if I could rewrite (or at least reorganize) that entire Hooks file for a while now 😉

@eidge
Copy link
Contributor Author

eidge commented Jan 28, 2015

Yup the hooks file does look a bit smelly. It's fine by me, I just want to see this fixed ;)

Personally, I would include the ApiPagination.config function in the solution and take the chance to include customizable defaults such as per_page and max_per_page.

Summing up, it's fine if you want to implement it yourself but I'll be glad to implement it if you do want to point me in the right direction :)

Cheers

@davidcelis
Copy link
Owner

Yup, my plan is to include a better configuration pattern but to include defaults if it isn't configured 😄

@eidge
Copy link
Contributor Author

eidge commented Jan 28, 2015

Seems like a plan. Do you want to sketch up an implementation or implement
it yourself?

Hugo Ribeira

Jack of All Trades at *intoCros http://intocross.coms
http://intocross.com *
Tel: +351 910982209 http://910982209 * LinkedIn
http://pt.linkedin.com/pub/hugo-ribeira/45/295/536/ * GitHub
https://github.com/eidge
Universidade de Coimbra

2015-01-28 18:55 GMT+00:00 David Celis [email protected]:

Yup, my plan is to include a better configuration pattern but to include
defaults if it isn't configured [image: 😄]


Reply to this email directly or view it on GitHub
#33 (comment)
.

@davidcelis
Copy link
Owner

I think I'll take a look at it since I've been meaning to do this for a while. No time like the present!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants