-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Custom Search
Sébastien Dubois edited this page Jun 3, 2019
·
3 revisions
You can add your custom search method instead of using the default search. This will help you to add any type of association even if you don't want to show them on the listing page.
config.model Player do
list do
search_by :my_search
end
end
class Player < ApplicationRecord
scope :my_search, -> (keyword) { where(name: keyword) }
end
config.model Player do
list do
search_by :my_search
end
end
class Player < ApplicationRecord
pg_search_scope :my_search,
:against => [:id],
:associated_against => {
translations: :name
},
using: {
tsearch: {any_word: true,},
trigram: {threshold: 0.1}
}
end