Sha256: 3468894538032a226fa8ddd97fdeff175a30f291cd06d8277af76000ff6f28a1
Contents?: true
Size: 811 Bytes
Versions: 2
Compression:
Stored size: 811 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, lambda { |*args| if PgSearch.multisearch_options.respond_to?(:call) options = PgSearch.multisearch_options.call(*args) else options = PgSearch.multisearch_options.reverse_merge(:query => args.first) end options.reverse_merge(: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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pg_search-0.4 | lib/pg_search/document.rb |
pg_search-0.3.4 | lib/pg_search/document.rb |