Module: ActiveAdminAssociations::Autocompleter::AutocompleteMethods

Defined in:
lib/active_admin_associations/autocompleter.rb

Instance Method Summary collapse

Instance Method Details

#autocomplete_results(query) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/active_admin_associations/autocompleter.rb', line 18

def autocomplete_results(query)
  results = where("LOWER(#{table_name}.#{autocomplete_attribute}) LIKE ?", "#{query.downcase}%").
    order("#{table_name}.#{autocomplete_attribute} ASC")
  results.map do |record|
    _autocomplete_format_result(record)
  end
end