Skip to content

Custom scopes don't work with Ajax Select #407

Open
@thisismydesign

Description

@thisismydesign

Seems like groupings and custom scopes don't play nice in ransack: activerecord-hackery/ransack#1339

The Ajax select will always structure the query in a grouping:

var query = {
order: order,
q: {
groupings: [textQuery],
combinator: 'and',
},
};

Even in the case of a single parameter. A simple query will look something like this:

image

Would it be possible not to use groupings unless necessary? As long as custom scopes are passed on top-level this would enable filtering to work with custom scopes. It would also make queries easier to understand. The following are equivalent

{ groupings: [{m: 'or', user_name_contains: 'hug'}, combinator: 'and']}
# vs
{ user_name_contains: 'jov' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions