I'm trying to add a custom filter to ActiveAdmin which is powered by Ransack these days. Unfortunately, ransacker
is not documented at all and from the few resources online I fumbled together the following (in the User model):
ransacker :full_text, formatter: ->(search) {
ids = User.search_in_all_translated(search).map(&:id)
ids = ids.any? ? ids : nil
} do |parent|
parent.table[:id]
end
The search_in_all_translated
method returns an array of users which match the search string across all translated attributes.
On the admin page, the following filter is defined:
filter :full_text_in,
label: 'full text search',
as: :string
The filter itself works, so filtering tom
will list all matching records. However, the value in the filter input switches to ["tom"]
.
Before applying the filter:
After applying the filter:
Any ideas how to fix this?
full_text_in
, which basically implies that the search filter will be an array of inputs. I am not sure, but maybe you can try:full_text_eq
instead. – BowdenWHERE "users"."id" = 8464, 28139, 13076, 3088
. – Differentiate