In the past:
A model User
has a string filed first_name
. If I write filter :first_name
in ActiveAdmin model it would display a drop-down besides the input field with the options Contains
, Equals
, Starts with
, Ends with
. So for examle if I choose Contains
and write ik
, it would find, for example Mike.
Now:
If I use a custom filter I just get a large input, spanning across two columns, which only does exact search. I define my filter like so:
- Create a scope in the model.
- Whitelist it with
ransackable_scopes
. - Add it to the admin model like so:
filter :my_filter, as: :string
.
How do I get the functionality to seach for substrings?
To search for substrings you must use the Ransack Search Predicate Syntax i.e. if you want search a substring on field
first_name
you must configure this way:You can find more information here
I hope it helps.