app/models/concerns/searchable.rb
# runs after save to update the searchable table
runs after save to update the searchable table
runs after save to update the searchable table
def index_search_document
    searchable = search_document
    searchable = create_search_document if searchable.nil?
    if search_options[:if].present? && !send(search_options[:if])
      searchable.content = ""
      searchable.save
    else
      searchable.content = searchable_content
      Array(search_options[:with_fields]).each do |extra_field|
        searchable[extra_field] = send(extra_field)
      end
      searchable.save
    end
  end
def index_search_document searchable = search_document searchable = create_search_document if searchable . nil? if search_options [ :if ] . present? && ! send ( search_options [ :if ] ) searchable . content = "" searchable . save else searchable . content = searchable_content Array ( search_options [ :with_fields ] ) . each do | extra_field | searchable [ extra_field ] = send ( extra_field ) end searchable . save end end
runs after save to update the searchable table
runs after save to update the searchable table
# make sure the search document exists # if an 'if:' was passed to the options, # make sure it passes before adding any more content # update the content # update any extra fields # save the document