Sha256: 8ce89d42e6f5bae781285b241899d65930e09807ba673ee177a55c5d70b6846e
Contents?: true
Size: 949 Bytes
Versions: 3
Compression:
Stored size: 949 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.wrap(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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pg_search-0.5.4 | lib/pg_search/document.rb |
pg_search-0.5.3 | lib/pg_search/document.rb |
pg_search-0.5.2 | lib/pg_search/document.rb |