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

Handling search for multi-select checkboxes #6

Open
steveyken opened this issue Jan 2, 2014 · 3 comments
Open

Handling search for multi-select checkboxes #6

steveyken opened this issue Jan 2, 2014 · 3 comments

Comments

@steveyken
Copy link
Member

When searching for values in checkbox custom fields, ransack_ui doesn't generate the correct SQL for finding items.

Current SQL is

SELECT DISTINCT opportunities"."id" FROM "opportunities" WHERE "opportunities"."cf_engagement_stuff" = 'project funding' AND ('t'='t')

And the data in the table is stored in a YAML array format as:


---
- project funding
- option three
- ''

This would be picked up in a ransack contains query but not an 'is query. However, is is the only option as contains has disappeared in the most recent version.

Is there an easy way to get the following like query back via the contains option?

SELECT DISTINCT opportunities.id FROM "opportunities"
WHERE "opportunities"."cf_engagement_stuff" ILIKE '%project funding%' AND ('t'='t')
@steveyken
Copy link
Member Author

Basically, swapping 'is' for 'contains' on fields that are multi-select would be awesome. Can you point me in the right direction to fix this?

@steveyken
Copy link
Member Author

@ndbroadbent any hints on how to change an 'is' to a 'contains' will try to look at this tomorrow.

@steveyken
Copy link
Member Author

My internal hack was to do Ransack.option_predicates.push('cont') but perhaps need to do something better here.

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

No branches or pull requests

1 participant