Created
May 16, 2013 13:37
-
-
Save allaire/5591790 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PgSearch.multisearch_options = { | |
:using => { tsearch: { prefix: true } } | |
} | |
module PgSearch | |
class Document < ActiveRecord::Base | |
before_save do | |
self.organization_id = searchable.organization_id | |
end | |
end | |
end | |
PgSearch::Multisearch::Rebuilder.send(:remove_const, :REBUILD_SQL_TEMPLATE) | |
module PgSearch | |
module Multisearch | |
class Rebuilder | |
private | |
REBUILD_SQL_TEMPLATE = <<-SQL.strip_heredoc | |
INSERT INTO :documents_table (searchable_type, searchable_id, content, created_at, updated_at, organization_id) | |
SELECT :model_name AS searchable_type, | |
:model_table.id AS searchable_id, | |
( | |
:content_expressions | |
) AS content, | |
:current_time AS created_at, | |
:current_time AS updated_at, | |
:model_table.organization_id | |
FROM :model_table | |
SQL | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment