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

Allow overriding the query and keeping the default logic applied to it on dynamic filters #3644

Open
Paul-Bob opened this issue Feb 6, 2025 · 1 comment
Labels
Enhancement Not necessarily a feature, but something has improved

Comments

@Paul-Bob
Copy link
Contributor

Paul-Bob commented Feb 6, 2025

When defining a query block on a dynamic filter, the default logic applied by Ransack behind the scenes is overridden, giving the developer full control over the application of the query logic.

This is great, however, sometimes, that is not the desired behavior. For example, we may want to retain the default behavior but wrap the query in a scope to apply the Mobility gem.

In such cases, a helper that applies the default query logic would be helpful.

I don't have a clear vision of what it would look like, but here are some ideas:

  1. Pass two queries to the query block.
    field :tourist_destination, as: :boolean, filterable: {
      query: -> {
        query # clean query
        query_with_defaults # query with defaults applied
      }
    }
  1. Add a helper that applies defaults.
    field :tourist_destination, as: :boolean, filterable: {
      query: -> {
        query = apply_defaults(query: query)
      }
    }
@Paul-Bob Paul-Bob added the Enhancement Not necessarily a feature, but something has improved label Feb 6, 2025
@Paul-Bob Paul-Bob moved this to Triage in Issues Feb 6, 2025
Copy link
Contributor

This issue has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label Feb 22, 2025
@Paul-Bob Paul-Bob removed the Stale label Feb 24, 2025
@adrianthedev adrianthedev removed the status in Issues Mar 5, 2025
@adrianthedev adrianthedev moved this to Triage in Issues Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Not necessarily a feature, but something has improved
Projects
Status: Triage
Development

No branches or pull requests

1 participant