Add pagy for following route
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! :tada:
Here is how you may implement pagy for this: -
-
Select action
followingunderusers_controller -
Since here pagination is already implemented using
will_paginateas.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_paginateline 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
@pagyvariable 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!
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 https://github.com/publiclab/plots2/pull/8428 https://github.com/publiclab/plots2/pull/8326
Hello, can I work on this issue?
Hey @stacytonui go ahead 🎉
Thanks @Tlazypanda I've linked the PR. Kindly review it