Comments (7)
The :page
variable does not get ignored: the execution doesn't even arrive to create the Pagy
instance, because the Pagy::Backend
is assuming there is a params
method in your controller.
Please, take a look at the Environment Assumptions for clue about why that happens and how to easily avoid it.
from pagy.
From that page:
However you can force a page number by just passing it to the pagy method. For example:
@pagy, @records = pagy(my_scope, page: 3)
That will explicitly set the:page
variable, overriding the default behavior (which usually pulls the page number from theparams[:page]
).
Doesn't this mean that I don't need a params
variable/method at all, if I am always explicitly setting the page number?
from pagy.
from pagy.
In other words: you have first to satisfy the environment assumptions (which require a params
method or an overridden pagy_get_vars
that avoids to call it), and then if you want explicitly override the :page
variable you can pass it to the pagy
method. However that is for single instance overriding or variable addition.
Since you have to override the pagy_get_vars
to avoid the params
call, I would suggest you to set the :page
in that method, which raison d'Γͺtre is exactly collecting the variables (including the :page
) for the Pagy
creation.
BTW, what framework are you using and where do you get the :page
from?
from pagy.
You may also want to read the Pagy::Backend doc that could give you more insights about the pagy
method.
from pagy.
Thanks for clearing that up. I managed to set the page number by overriding pagy_get_vars
so the page
option is given preference, as this seems to be the only way to get it working with the framework I'm using.
I'm using Middleman and Sequel together. The page number is passed as a local variable directly to a template, and bypasses the file that overrides pagy_get_vars
. That's why it wasn't clear how to set it up.
from pagy.
Glad that you made it work.
However, overriding pagy_get_vars
is not the only way. You can write your own pagy
method and bypass the pagy_get_*
methods altogether.
For sequel you need also to override he :count
assignment from collection.count(:all)
to collection.count
(but you should already know that by now).
from pagy.
Related Issues (20)
- Add ARIA attributes to foundation helpers
- Add ARIA attributes to materialize helpers
- Add ARIA attributes to semantic helper
- Add ARIA attributes to uikit helper
- Bug: pagy_search wrong number of arguments HOT 10
- Bug: Alias for an aggregate result is removed HOT 9
- Bug: Issue with Arel scope passed to pagy method HOT 3
- Docs: 7.0 has an undocumented breaking change for active page styling HOT 5
- Docs: Which branch should PRs be made against? HOT 3
- Docs: Update performance metrics HOT 5
- Trim doesn't call with pagy_nav_js when first page is active
- Bug: Adapt with Mongoid add extention HOT 1
- Bug: Pagy::Backend#pagy_get_vars `count_args` gets ignored HOT 3
- Docs: https://ddnexus.github.io/pagy/quick-start/#configure HOT 1
- Bug: Missing initializer in documentation HOT 1
- Bug: wrong number of arguments (given 2, expected 0) HOT 2
- Bug: wrong number of arguments (given 2, expected 0) HOT 1
- Bug: Pagy not working with Geocoder gem
- Bug: Undocumented backwards-incompatible change of empty "page" parameter introduced in 6.4.0 HOT 3
- Docs: lost section about wrap existing pagination with pagy_calendar 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 pagy.