Skip to content

Conversation

thisismydesign
Copy link

Fixes #407

AFAICT the following queries are equivalent:

User.ransack({ groupings: [{m: 'or', firstname_contains: 'a', lastname_contains: 'a'}, combinator: 'and']}).result.to_sql
# "SELECT \"users\".* FROM \"users\" WHERE \"users\".\"deleted_at\" IS NULL AND (\"users\".\"firstname\" ILIKE '%a%' OR \"users\".\"lastname\" ILIKE '%a%')"

User.ransack({m: 'or', firstname_contains: 'a', lastname_contains: 'a'}).result.to_sql
# "SELECT \"users\".* FROM \"users\" WHERE \"users\".\"deleted_at\" IS NULL AND (\"users\".\"firstname\" ILIKE '%a%' OR \"users\".\"lastname\" ILIKE '%a%')"

Simplifying the query sent to activeadmin allows for custom scopes to be used in ajax select fields. It also simplifies the query :)

I didn't modify nested_select, I suspect that this implementation with grouping was made for that use case and then re-used for the more simple ones.

@thisismydesign
Copy link
Author

CI failure:

lint - Unauthorized

@thisismydesign
Copy link
Author

@ldlsegovia any chance you can take a look at this pr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Custom scopes don't work with Ajax Select
1 participant