Class: Ucpengine::EntrySearchData

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/ucpengine/entry_search_data.rb

Class Method Summary collapse

Class Method Details

.index_entry_data(entry_id, search_attributes) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'app/models/ucpengine/entry_search_data.rb', line 8

def self.index_entry_data(entry_id, search_attributes)
  search_attributes.each do |attr_name, value|
    find_or_create_by(entry_id: entry_id, attr_name: attr_name)

    where(entry_id: entry_id, attr_name: attr_name).update_all([
      "raw_data = :search_data, search_data = to_tsvector('english', :search_data)",
      search_data: value
    ])
  end
end