plots2 icon indicating copy to clipboard operation
plots2 copied to clipboard

Add pagy for following route

Open Tlazypanda opened this issue 6 years ago • 3 comments

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 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!

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

Tlazypanda avatar Oct 14 '20 08:10 Tlazypanda

Hello, can I work on this issue?

stacytonui avatar Oct 14 '20 08:10 stacytonui

Hey @stacytonui go ahead 🎉

Tlazypanda avatar Oct 14 '20 09:10 Tlazypanda

Thanks @Tlazypanda I've linked the PR. Kindly review it

stacytonui avatar Oct 14 '20 11:10 stacytonui