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 option to configure the cursor/param name #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marianposaceanu
Copy link

Description

This pull request adds the ability to customize the cursor query parameter name.

Changes

The cursor_name configuration option can now be set to a custom value in the GearedPagination.configure block. By default, the cursor parameter is named :page, but it can now be customized.

The reason for this change is to provide more flexibility for developers who may want to use a different query parameter name for pagination cursors, for example to avoid conflicts with other query parameters in their application or where the FE expects a specific name for the cursor param.

Usage

GearedPagination.configure do |config|
  config.cursor_name = :cursor
end

You can also use the cursor parameter name in your links to generate pagination URLs:

<%= link_to "Next page", messages_path(cursor: @page.next_param) %>

This will generate a URL with a ?cursor=<next_cursor> query parameter instead of ?page=<next_page>.

Additional Notes

This pull request includes tests to ensure that the cursor_name option is working as expected, and that links with custom cursor parameter names are generated correctly.

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.

1 participant