Comments (9)
That's weird. Did you override some method?
from pagy.
Here's all the code I've added or modified for Pagy.
In my controller:
def index
<SNIP>
@pagy, @equities = pagy(Equity.search(@search_params))
end
def pagy_get_vars(collection)
{ count: collection.count(:all) }
end
In my view:
= pagy_nav_bootstrap(@pagy).html_safe
(I also tried = pagy_nav(@pagy).html_safe
with the same result`
In my helper:
def pagy_url_for(n)
params = request.query_parameters.merge(anchor: 'results_section', page: n)
url_for(params)
end
from pagy.
Oh, and if it makes a difference, I'm running Pagy 0.6.0 instead of 0.7.0. I had to downgrade to 0.6.0 when I installed the pagy-extras gem due to:
pagy-extras was resolved to 0.1.2, which depends on
pagy (~> 0.6.0)
from pagy.
I see. With the overriding of pagy_get_vars
you are actually wiping out the page: params[:page]
, so pagy will always point to page number 1.
You should not override that method and I suspect all will work as expected. Or if you really have to, ensure you will leave the :page
variable in the returned hash
from pagy.
I will fix the pagy-extra
dependency error with the next push tomorrow. Thanks.
from pagy.
@ddnexus Thanks! Adding page: params[:page]
back to pagy_get_vars
fixed this problem. FYI, I had to override that method because the count
that was called caused a PostgreSQL error. I have to do count(:all)
in several places in my app to avoid that SQL issue.
from pagy.
Good to know then. I am not very familiar with PostgreSQL: is that the way you are supposed to write it, or is that the fix for a problem with the adapter or the version or something else?
from pagy.
There's a brief discussion about it here https://stackoverflow.com/questions/18252570/rails-difference-between-model-count-and-model-countall
I guess you can call it a quirk between Rails and Postgres. With certain queries the count
SQL statement Rails produces (something like count(col 1, col2, col3...)
causes an exception in PG. So using count(:all)
makes Rails issue a simple count(*)...
Here's one I hit a few hours ago while converting from Kaminari to Pagy:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR: function count(character varying, character varying, timestamp without time zone) does not exist
LINE 1: SELECT COUNT(url, title, published_at) FROM "articles" WHERE...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
: SELECT COUNT(url, title, published_at) FROM "articles" WHERE "articles"."equity_id" = $1
from pagy.
Thanks for explaining that.
from pagy.
Related Issues (20)
- Add pt-BR: "pagination" entry HOT 2
- Add ru: "pagination" entry
- Add sr: "pagination" entry HOT 2
- Add sv: "pagination" entry HOT 2
- Add sv-SE: "pagination" entry HOT 1
- Add sw: "pagination" entry HOT 2
- Add ta: "pagination" entry HOT 1
- Add tr: "pagination" entry HOT 3
- Add uk: "pagination" entry HOT 3
- Add vi: "pagination" entry HOT 5
- Add zh-CN: "pagination" entry HOT 1
- Add zh-HK: "pagination" entry HOT 1
- Add zh-TW: "pagination" entry HOT 1
- Add ARIA attributes to pagy helpers
- Add ARIA attributes to bootstrap helpers
- Add ARIA attributes to bulma helpers
- Add ARIA attributes to foundation helpers
- Add ARIA attributes to materialize helpers
- Add ARIA attributes to semantic helper
- Add ARIA attributes to uikit helper
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.