Sha256: 3234893fb4294cb6b7047e16da7198709da9a18fe90e7d86682ae5e3f875ae18

Contents?: true

Size: 539 Bytes

Versions: 4

Compression:

Stored size: 539 Bytes

Contents

require "pg_search/scope"

module PgSearch
  class Document < ActiveRecord::Base
    include PgSearch
    set_table_name :pg_search_documents
    belongs_to :searchable, :polymorphic => true

    before_validation :update_content

    pg_search_scope :search, :against => :content

    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

4 entries across 4 versions & 1 rubygems

Version Path
pg_search-0.3.3 lib/pg_search/document.rb
pg_search-0.3.2 lib/pg_search/document.rb
pg_search-0.3.1 lib/pg_search/document.rb
pg_search-0.3 lib/pg_search/document.rb