Sha256: 466292cd6395b404250a9e4871b9148b9a7b830f3a882c26f5f43e2686c9ce11
Contents?: true
Size: 944 Bytes
Versions: 13
Compression:
Stored size: 944 Bytes
Contents
require "logger" module PgSearch class Document < ActiveRecord::Base include PgSearch self.table_name = 'pg_search_documents' belongs_to :searchable, :polymorphic => true before_validation :update_content # The logger might not have loaded yet. # https://github.com/Casecommons/pg_search/issues/26 def self.logger super || Logger.new(STDERR) end pg_search_scope :search, lambda { |*args| options = if PgSearch.multisearch_options.respond_to?(:call) PgSearch.multisearch_options.call(*args) else {:query => args.first}.merge(PgSearch.multisearch_options) end {:against => :content}.merge(options) } private def update_content methods = Array(searchable.pg_search_multisearchable_options[:against]) searchable_text = methods.map { |symbol| searchable.send(symbol) }.join(" ") self.content = searchable_text end end end
Version data entries
13 entries across 13 versions & 1 rubygems