Questions tagged [pagy]
27 questions
2
votes
1 answer
Use of Pagy rubygem in Rails tests with MiniTest
I have a Rails app that I have upgraded from Rails 6 to 7 app. In previous version I was using will_paginate gem (v. 3.3.1) and Bootstrap 3. Now I have decided to switch to pagy (v. 5.10.1).
I have followed the migration guide and made necessary…

msuliq
- 150
- 1
- 12
2
votes
0 answers
How to paginate an array with Pagy and Stimulus.js?
I am paginating an array that I am loading page per page when I scroll to the bottom of my page. Unfortunately it seems that some chunks of my array keep coming back instead of having the newly loaded bit of array. Any idea what this is happening…

Maxime Seiter
- 21
- 2
2
votes
2 answers
How to made a redirection if overflow on pagy array
I have an index view with 45 products and 3 pages.
I'm using pagy_array like :
@pagy, @products = pagy_array(products, items: 20)
If I delete 6 products, I get 39 items on 2 pages. But Google have indexed the third page, and when a customer come on…

Ben
- 660
- 5
- 25
1
vote
2 answers
CanCanCan, Pagy, and MeiliSearch, How to combine the 3 gems?
I'm working on a project that has Cue model that could be accessed and searched by multiple roles like guest and admin. The authorization happens using CanCanCan gem based on some logic written in the Ability class. While the search happens using…

AliOsm
- 541
- 2
- 6
- 20
1
vote
2 answers
Rails pagy route without pagination
I have a Rails API app. I use Pagy nicely and works perfectly. However, I would like to call the same route|service|endpoint for getting all records, ignoring pagination. Is this possible?

Montells
- 6,389
- 4
- 48
- 53
1
vote
3 answers
Why does Postgres not accept my count column?
I am building a Rails app with the following models:
# vote.rb
class Vote < ApplicationRecord
belongs_to :person
belongs_to :show
scope :fulfilled, -> { where(fulfilled: true) }
scope :unfulfilled, -> { where(fulfilled: false) }
end
#…

Christoffer Reijer
- 1,925
- 2
- 21
- 40
1
vote
1 answer
How to paginate multiple models with the Pagy gem in Rails?
I'm using Searchkick with the Pagy gem to paginate my search results and it works great if I'm only searching and paginating on one model, but I can't figure out how to do this with Pagy when I need to combine multiple models into one set of…

Lee McAlilly
- 9,084
- 12
- 60
- 94
1
vote
0 answers
Infinte-scroll Rails and Webpacker Failed to load resource: the server responded with a status of 406 (Not Acceptable)
I tried successfully to reproduce the tutorial of GoRails about the infinite scroll with stimulus https://gorails.com/episodes/infinite-scroll-stimulus-js on a new Rails 6 project , but impossible to reproduce to a older and bigger project updated…

Nicolas
- 43
- 6
1
vote
3 answers
How to enable fancy-routes for Pagy Gem in Rails 6 app
I'm trying to replace ?page= with /page/2 for all paginated pages in my Rails 6 application, so that I can be able to use Page Caching according to this guide.
I'm using the Pagy gem for pagination and according to their documentation, I should be…

tommers
- 51
- 7
1
vote
1 answer
Pagy : How to keep consistent loop index across pages?
I get a pg result with a postgres query like
ActiveRecord::Base.transaction do
ActiveRecord::Base.connection.execute(distance_sql)
end
And some variables
ids = result.column_values(1)
@kms = result.column_values(6)
towns =…

Ben
- 660
- 5
- 25
0
votes
0 answers
Retaining ElasticSearch query limit when working with Pagy gem
Ahoy fellow developers!
I have a problem with limiting the total number of search results in my web application.
The web app is written in Ruby, the search functionality is powered by ElasticSearch, and the pagination is handled by the Pagy ruby gem…

pnchkir
- 1
- 1
- 3
0
votes
1 answer
Delete link_to with turbo_confirm and HTML redirect
I’m trying to delete an article via link_to or button_to and afterwards redirect to another page (e.g. html response). Before I want to present the turbo_confirm dialog (I know I can use UJS but what’s the point of having UJS just for this?).
<%=…

Randomtheories
- 1,220
- 18
- 22
0
votes
0 answers
I have two models (events & artists) pagy is working fine with my artist model, but my event model isn't displaying last records
I do have a more elaborate index method in my events controller
def index
if params[:q]
params[:q][:combinator] = "and"
params[:q][:groupings] = []
split_geo =…

Ogarocious
- 119
- 6
0
votes
1 answer
Rails query to order records by single association row column
Say I have a books table that has id and name columns and a has_many book_ratings association. The book_ratings table has id, rating, rating_date, and book_id columns and belongs_to :book. I'm displaying the books in a table with 3 columns: the…

Paul
- 170
- 2
- 9
0
votes
0 answers
Use Pagy gem with group_by in Rails
I've created a Resource where I want to group each response by an attribute from an belong_to association.
I've accomplished that with the following code:
fixtures_controller.rb
def index
@q = Fixture.ransack(params[:q])
scope =…

tommers
- 51
- 7