vigetlabs / active_admin_associations

This extends ActiveAdmin to allow for better editing of associations.
MIT License
119 stars 55 forks source link

Find all records in Postgres #20

Open kevinjbayer opened 9 years ago

kevinjbayer commented 9 years ago

I'm guessing this is maybe a Postgres thing, but in order for the autocomplete to find all records that contain the query, instead of just finding records that begin with the query, the query in autocompleter.rb needs to be updated to this:

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

Note the additional percent sign at the beginning of query.downcase. I would think this should be default, but again, maybe this is just a Postgres thing.