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

Adding paginated? helper to active record extensions and page scope methods #1118

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jarenas9539
Copy link

@jarenas9539 jarenas9539 commented Feb 4, 2024

Main Purpose

Adding a paginated? helper to PageScopeMethods and AR extensions.

Context

Lately I found myself implementing a See All option in a few pages. As expected I had to find a way to conditionally render paginate section leading to conditions on views as relation.respond_to?(:total_pages) or relation.limit_value.present?.
That was the moment when the paginated? helper came to my mind, a simple and clean method to achieve this check.

Changes

  • adding paginated? with default value false to AR relations to have it available even if pagination method wasn't called
  • defining paginated? on PageScopeMethods relying on limit_value (this way we ensure the helper being true just when the pagination method is called and include support to possible unscope calls too)
  • added tests ✅
  • updated README

On a separated note: contributions section on README should be updated, current lines described there to run specs are relying on removed gemfiles/*

@yuki24
Copy link
Member

yuki24 commented Feb 5, 2024

Looks good to me 👍

@amatsuda What do you think of this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants