Module: Alchemy::PgSearch::PageExtension

Defined in:
app/extensions/alchemy/pg_search/page_extension.rb

Overview

Enable Postgresql full text indexing.

Class Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/extensions/alchemy/pg_search/page_extension.rb', line 4

def self.prepended(base)
  base.include PgSearch::Model
  base.after_save :remove_unpublished_page
  base.multisearchable(
    against: [
      :name,
      :searchable_content
    ],
    additional_attributes: ->(page) { { page_id: page.id, searchable_created_at: page.public_on } },
    if: :searchable?,
  )
end