You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please describe the desired behavior.
Pagy is a pagination gem used for its peak performance over other pagination tools. As mentioned #8426 we have been trying to migrate our codebase from will_paginate to pagy gem and would love your help with it! 🎉
Here is how you may implement pagy for this: -
Select action following under users_controller
Since here pagination is already implemented using will_paginate as .paginate(page: params[:page], per_page: 10) you can remove this line so that the method now looks like
@users = @user.following_users
Now add the pagy method in this action as - @pagy, @users = pagy(@user.following_users, items: 10)
Here 10 represents the items to be displayed on each page. This is the most basic way we can use pagy over any action: - @pagy, @records = pagy(Product.some_scope)
Now move to the html code which is generated for this controller users/show_follow.html
Search for the will_paginate line and replace it with -
<% if @pagy %> <%= raw pagy_bootstrap_nav @pagy %> <% else %> <%= will_paginate @users, renderer: WillPaginate::ActionView::BootstrapLinkRenderer %> <% end %>
This will now check if @pagy variable is available or not and then if present will generate pagination using pagy.
Awesome, create a pull request for the same and add screenshots if relevant!
Please describe the desired behavior.
Pagy is a pagination gem used for its peak performance over other pagination tools. As mentioned #8426 we have been trying to migrate our codebase from will_paginate to pagy gem and would love your help with it! 🎉
Here is how you may implement pagy for this: -
Select action
following
underusers_controller
Since here pagination is already implemented using
will_paginate
as.paginate(page: params[:page], per_page: 10)
you can remove this line so that the method now looks like@users = @user.following_users
Now add the pagy method in this action as -
@pagy, @users = pagy(@user.following_users, items: 10)
Here 10 represents the items to be displayed on each page. This is the most basic way we can use pagy over any action: -
@pagy, @records = pagy(Product.some_scope)
users/show_follow.html
will_paginate
line and replace it with -<% if @pagy %> <%= raw pagy_bootstrap_nav @pagy %> <% else %> <%= will_paginate @users, renderer: WillPaginate::ActionView::BootstrapLinkRenderer %> <% end %>
@pagy
variable is available or not and then if present will generate pagination using pagy.Additional context (optional)
In case of queries please checkout the following links for help: -
https://ddnexus.github.io/pagy/how-to
https://ddnexus.github.io/pagy/migration-guide
#8428
#8326
The text was updated successfully, but these errors were encountered: