Rails, find country based on city with ajax in realtime ( autocomplete)
Im looking for an autocomplete ajax implementation for a textfield.
- you type your city
- it wil look for closest match in db as you type
- as soon as it finds the city (partially search) it displays some options to choose from in format city, state you can pick one from the list and the textfield would contain " city, state"
What would be good ways of doing this in rails? I think i need an autocomplete functionality for this with an ajax posting to the app
So, very approximately, you'd do something like:
class CityController << ApplicationController def lookup cities = City.find_by_name(params[:city]) render :json => cities end end