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:
ransackable_scopes
. 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 ie if you want search a substring on field first_name
you must configure this way:
filter :first_name_cont, as: :string, label: "Name"
You can find more information here
I hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.