Forum: Ruby on Rails simple realtime search not working with utf8 on rails 1.2

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Patrick A. (Guest)
on 2007-01-20 00:44
(Received via mailing list)
hey all,
I have this peace of code:

# new.rhtml:
<% form_tag :action => 'create' do %>
  <%= render :partial => 'form' %>
  <%= submit_tag "Create" %>
<% end %>

# _form.rhtml:
<p><label for="list_title">Title</label><br/>
<%= text_field 'list', 'title'  %></p>

<%= observe_field 'list_title',  :frequency => 0.5,
         :update => 'results', :url =>
         { :controller => 'lists', :action=> 'search' },
         :with => "'list[title]=' + escape(value)" %>

<div id="results">

  def search
@title = params['list']['title']
@titles = List.find(:all,:conditions=>['title like ?', "%#{@title}%"])

it works great, as I type results are displayed in my results div. But
if I try to enter letters with accents like éçèà then nothing get
displayed. as an exemple if I type 'test éàç' in the text box I get
from development.log:

Processing ListsController#search (for at 2007-01-20 00:28:11)
  Session ID: 4fa4b22bbeed42322744501e09eb5601
  Parameters: {"list"=>{"title"=>"test "}, "action"=>"search",
  List Load (0.001703)   SELECT * FROM lists WHERE (title like '%test

any idea how to make it see unicode stuff right?

thanx in advance

Patrick A. (Guest)
on 2007-01-20 01:16
(Received via mailing list)
On 1/19/07, Patrick A. <removed_email_address@domain.invalid> wrote:

> <%= observe_field 'list_title',  :frequency => 0.5,
>          :update => 'results', :url =>
>          { :controller => 'lists', :action=> 'search' },
>          :with => "'list[title]=' + escape(value)" %>
ok, it works great if  replace escape(value) with value :)
is it better to use escape though?
This topic is locked and can not be replied to.