Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pagy for following route #8574

Closed
Tlazypanda opened this issue Oct 14, 2020 · 3 comments · Fixed by #8577
Closed

Add pagy for following route #8574

Tlazypanda opened this issue Oct 14, 2020 · 3 comments · Fixed by #8577
Labels
feature explains that the issue is to add a new feature help wanted requires help by anyone willing to contribute

Comments

@Tlazypanda
Copy link
Collaborator

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!

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

@Tlazypanda Tlazypanda added feature explains that the issue is to add a new feature help wanted requires help by anyone willing to contribute labels Oct 14, 2020
@stacytonui
Copy link
Contributor

Hello, can I work on this issue?

@Tlazypanda
Copy link
Collaborator Author

Hey @stacytonui go ahead 🎉

@stacytonui
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature explains that the issue is to add a new feature help wanted requires help by anyone willing to contribute
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants