Module: SearchAutocomplete::Autocompletable::ClassMethods

Defined in:
lib/search_autocomplete/autocompletable.rb

Overview

Autocompletable methods

Instance Method Summary collapse

Instance Method Details

#autocomplete(search_field, display_fields = [], filters = []) ⇒ Object

Configures this model to respond to autocomplete searches

Parameters:

  • search_field (String|Array)

    Name of the main field to perform the search. If an array is given it will search in a jsonb structure.

  • display_fields (Array{Symbol}) (defaults to: [])

    Array of field names for concatenating as display result

  • filters (Array{Symbol}) (defaults to: [])

    Array of additional fields to filter



22
23
24
25
26
27
28
29
# File 'lib/search_autocomplete/autocompletable.rb', line 22

def autocomplete(search_field, display_fields = [], filters = [])
  self.autocomplete_options = {
    configured: true,
    search_field: search_field,
    display_fields: display_fields.size.zero? ? [search_field] : display_fields,
    filters: filters
  }
end