Files
old-holivud2/app/models/concerns/searchable.rb
2020-05-31 22:38:19 +02:00

28 lines
540 B
Ruby

module Searchable
extend ActiveSupport::Concern
included do
include PgSearch
end
class_methods do
def searchable_on(fields)
search_opts = {
against: fields,
associated_against: {
notes: [:content],
tags: [:name],
internal_tags: [:name]
},
using: {
tsearch: { any_word: true, prefix: true },
trigram: {},
dmetaphone: { any_word: true },
}
}
send(:pg_search_scope, :search, search_opts)
end
end
end