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

Custom scopes don't work with Ajax Select #407

Open
thisismydesign opened this issue Jun 9, 2022 · 1 comment · May be fixed by #408
Open

Custom scopes don't work with Ajax Select #407

thisismydesign opened this issue Jun 9, 2022 · 1 comment · May be fixed by #408

Comments

@thisismydesign
Copy link

thisismydesign commented Jun 9, 2022

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' }
@thisismydesign
Copy link
Author

Actually, I'm wondering if groupings is needed at all. For the purposes of this ajax call even in the case of multiple fields isn't these 2 equivalent?

{ groupings: [{m: 'or', field1: 'value', field2: 'value'}, combinator: 'and']}
# vs
{m: 'or', field1: 'value', field2: 'value'}

Perhaps groupings are only needed for nested-select? If so, this part could be simplified & fixed.

@thisismydesign thisismydesign linked a pull request Jun 10, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant