Skip to content

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

@Paul-Bob

Description

@Paul-Bob

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)
      }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNot necessarily a feature, but something has improvedStale exempt

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions