Don't change the state of a 'request' entity using while the '#pagy_url_for' method for calendar pagination #688
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug that I faced trying to implement the calendar pagination.
Simple explanation:
While doing the calendar pagination I'm getting the next error
expected :page >= 1; got "__pagy_page__"
The bug:
I think it was added to the
pagy_url_for
method in this commit, where we assign therequest.Get
object to thequery_params
variable and later change this object in thepagy_set_query_params
method, so when after it we execute thepagy_url_for
again therequest.Get
object is different and generates us broken URL.How I'm reproducing it in my Rails app
gem 'pagy', '~> 8.1', '>= 8.1.2'
to my Gemfile (Rails project)include Pagy::Frontend
inApplicationHelper
include Pagy::Backend
in my controller@calendar, @pagy, @meals = pagy_calendar(collection, year: { }, month: { }, day: { })
in my action (e.g. index)pagy_nav...
in your view. For example<%== pagy_nav(@calendar[:year]) %>
&<%== pagy_nav(@calendar[:month]) %>
Check the bug in the playground
The bug is reproducible via Pagy Playground. Look at the images below as the proof: