Skip to content

Including first & last pages with pagy_nav? #694

Answered by benkoshy
excid3 asked this question in Q&A
Discussion options

You must be logged in to vote

Is there a way to have pagy_nav render the first / last pages still?

Yes.

If all you want is to render the first and last pages in addition to the others, all the time, you can do this by changing the size array:

pagy = Pagy.new count: 1000, page: 10, size: [1, 4, 4,1] # etc
pagy.series
#=>[1, :gap, 6, 7, 8, 9, "10", 11, 12, 13, 14, :gap, 50]

# so you may want to do something like in your FoosController.rb
@pagy, @foos = pagy(Foo.all, size: [1, 4, 4, 1])           

# or set a default in your pagy.rb initialiser if you want it globally set.
Pagy::DEFAULT[:size]    = [1, 4, 4,1]

Reference

https://ddnexus.github.io/pagy/docs/how-to/#control-the-page-links and checkout the session on "cla…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@excid3
Comment options

Answer selected by benkoshy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants