-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Custom Search
Roc Khalil edited this page Jun 1, 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
search_scope :my_search
end
class Player < ApplicationRecord
scope :my_search, -> (keyword) { where(name: keyword) }
end
config.model Player do
search_scope :my_search
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