Sha256: cc92727ba98241655357993e41e1e0f5606ffe3ba54005d6f26ba815534645e2

Contents?: true

Size: 606 Bytes

Versions: 12

Compression:

Stored size: 606 Bytes

Contents

module Ucpengine
  class EntrySearchData < ActiveRecord::Base
    belongs_to :entry

    validates :entry_id, presence: true
    validates :attr_name, presence: true, uniqueness: { scope: :entry_id }

    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
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ucpengine-0.1.2 app/models/ucpengine/entry_search_data.rb
ucpengine-0.1.1 app/models/ucpengine/entry_search_data.rb
ucpengine-0.1.0 app/models/ucpengine/entry_search_data.rb
ucpengine-0.0.9 app/models/ucpengine/entry_search_data.rb
ucpengine-0.0.8 app/models/ucpengine/entry_search_data.rb
ucpengine-0.0.7 app/models/ucpengine/entry_search_data.rb
ucpengine-0.0.6 app/models/ucpengine/entry_search_data.rb
ucpengine-0.0.5 app/models/ucpengine/entry_search_data.rb
ucpengine-0.0.4 app/models/ucpengine/entry_search_data.rb
ucpengine-0.0.3 app/models/ucpengine/entry_search_data.rb
ucpengine-0.0.2 app/models/ucpengine/entry_search_data.rb
ucpengine-0.0.1 app/models/ucpengine/entry_search_data.rb