Simple realtime search not working with utf8 on rails 1.2


#1

hey all,
I have this peace of code:

new.rhtml:

<% form_tag :action => ‘create’ do %>
<%= render :partial => ‘form’ %>
<%= submit_tag “Create” %>
<% end %>

_form.rhtml:

Title
<%= text_field 'list', 'title' %>

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

#controller:
def search
@title = params[‘list’][‘title’]
@titles = List.find(:all,:conditions=>[‘title like ?’, “%#{@title}%”])
end

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 127.0.1.1 at 2007-01-20 00:28:11)
[POST]
Session ID: 4fa4b22bbeed42322744501e09eb5601
Parameters: {“list”=>{“title”=>"test "}, “action”=>“search”,
“controller”=>“lists”}
List Load (0.001703) SELECT * FROM lists WHERE (title like ‘%test
%’)

any idea how to make it see unicode stuff right?

thanx in advance

Pat


#2

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 :slight_smile:
is it better to use escape though?