Skip to content

Narrow down items with multiple colums #206

@soujiro0725

Description

@soujiro0725

I have a model called Airport, which has three columns, name, city, and country.

I want autocomplete to narrow down the possible outcomes by typing name followed by city and country. How can I do that?

If my understanding is correct, I need to override the function

def get_autocomplete_items(parameters)
    super(parameters).where(:city => params[:city], :country => params[:country])
end

and add scopes

:scopes => [:city, :country]

in the form

<%= autocomplete_field_tag :departure_id, @departure_place,
autocomplete_airport_name_plans_path,
:size => 75, :scopes => [:city, :country], 'data-delimiter' => ' ' %>

But certainly it does not work. I am sure there must be a way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions