'Pagy gem not rendering all my records RAILS APP
Hey guys I have a problem with the pagy gem.
I have this query that returns all the Posts of my account, excepts the ones that have metrics with id: nil. In total, there are 43 posts.
@posts = Post.includes(:metric).where(account_id: current_account.id).where.not(metric: { id: nil })&.filtered(filter_params)
When I add pagy to it, it doesnt work correctly, it only renders 1 post per page.
@pagy, @posts = pagy(Post.includes(:metric).where(account_id: current_account.id).where.not(metric: { id: nil })&.filtered(filter_params))
IF i erase the where.not part it works, except in the last page, because i have a post with nil metrics.
@pagy, @posts = pagy(Post.includes(:metric).where(account_id: current_account.id)&.filtered(filter_params))
Someone has an idea of what could it be? Thanks <3
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
