lib/pg_search/document.rb in pg_search-0.4 vs lib/pg_search/document.rb in pg_search-0.4.1

- old
+ new

@@ -1,19 +1,26 @@ +require "logger" require "pg_search/scope" module PgSearch class Document < ActiveRecord::Base include PgSearch - set_table_name :pg_search_documents + 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| - if PgSearch.multisearch_options.respond_to?(:call) - options = PgSearch.multisearch_options.call(*args) + options = if PgSearch.multisearch_options.respond_to?(:call) + PgSearch.multisearch_options.call(*args) else - options = PgSearch.multisearch_options.reverse_merge(:query => args.first) + PgSearch.multisearch_options.reverse_merge(:query => args.first) end options.reverse_merge(:against => :content) } private