Skip to content

Commit

Permalink
Define a failsafe logger in PgSearch::Document
Browse files Browse the repository at this point in the history
If pg_search is required before the Active Record
logger is defined, and PgSearch::Document.search
is already defined, then this suppresses a
NoMethodException.
  • Loading branch information
nertzy committed Feb 13, 2012
1 parent 6c70658 commit bdcb9ea
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/pg_search/document.rb
Expand Up @@ -8,6 +8,12 @@ class Document < ActiveRecord::Base

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)
Expand Down

0 comments on commit bdcb9ea

Please sign in to comment.