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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
997433f165140d58f52b8c0d1d005dc1?d=identicon&s=25 Patrick Aljord (Guest)
on 2007-01-19 23: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)" %>
<!--[eoform:list]-->

<div id="results">
</div>

#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
997433f165140d58f52b8c0d1d005dc1?d=identicon&s=25 Patrick Aljord (Guest)
on 2007-01-20 00:16
(Received via mailing list)
On 1/19/07, Patrick Aljord <patcito@gmail.com> 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.