Now I have search_field
= f.search_field :name_cont
I want to create a list of extra words(tokens) that will show a different query.
For example, if I type John
it will show all Johns, but if I type []
it will show all users without a name.
One more: @
- will means users with a name.
New implementation also welcome.
In the controller, you can modify the search params according to any logic you like. Eg, assuming your search params are saved in a @search_params
(replace with whatever var has your search params, eg params[:q]
):
if @search_params[:name_cont] == "[]"
@search_params[:name_blank] = true
@search_params.delete(:name_cont)
end
if @search_params[:name_cont] == "@"
@search_params[:name_present] = true
@search_params.delete(:name_cont)
end
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.