We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
The text was updated successfully, but these errors were encountered:
@soichi777 currently autocompleting against multiple columns is not supported, but however there are some PRs addressing this issue.
Sorry, something went wrong.
If you really, really need it - read again: really need it - there is a way:
In your autocompleted controller, overwrite autocomplete method:
def autocomplete_user_name items = User.find_by_full_name params[:term] extra_data = [:middle_name, :last_name] display_value = :full_name render json: json_for_autocomplete(items, display_value, extra_data) end
This will work for any controller with: autocomplete :user, :name, full: true and User model with this method:
autocomplete :user, :name, full: true
User
def full_name "#{name} #{middle_name} #{last_name}" end
Anyway, @manusajith , there is a roadmap to continue this gem? I've already seen Rails 4 compatible fork; multiple rows fork and so on...
Thanks!
@hlegius the master branch currently supports rails4, we would be releasing a rails 4 compatible version of the gem soon.
We officially released a gem update with Rails 4 support in December. Work is still continuing on this gem.
No branches or pull requests
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
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.
The text was updated successfully, but these errors were encountered: