Gernot Kogler
2006-Apr-13 08:06 UTC
[Rails] text_field_with_auto_complete and foreign characters
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: <input type="text" id="city_name" name="city_name" size="40" /> <%= observe_field(:city_name, :frequency => 0.5, :update => :results, :url => { :controller => ''entries'', :action => :find_city, }, :with => "''city_name='' + escape($F(''city_name''))" )%> <div class="autocomplete" id="results"></div> 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" ? -- Posted via http://www.ruby-forum.com/.