I need a form where the user must enter a city name. I would like to use
an autocomplete_field for the city name, so I have the following code in
my view:
<%= text_field_with_auto_complete ‘entry’, ‘city_name’, :size => 40 %>
and in my controller I have the method:
def auto_complete_for_entry_city_name
@cities = City.find(:all,
:conditions => [ ‘LOWER(name) LIKE ?’,
params[:entry][:city_name].downcase + ‘%’],
:order => ‘name ASC’,
:limit => 10)
render :partial => ‘cities’
end
This works fine, except when the city name has german umlauts like in
‘Zürich’. It looks like I get the raw text from the city field in my
action method.
I then tried to use the observe_field feature like this:
This works fine with umlauts, too. The :with-option does the trick.
Unfortunately this is not what I need, I want an autocplete field. Is
there a way to escape the text from my input field using “the
text_field_with_auto_complete” ?