alo, aku coba bikin search script dapet dari tutorial di net. Langsung
ke pokok masalah pas aku coba si request/value input nya selalu ada
tambahan character "=", aku isi "test" output nya "test=" kira2 kenapa
yah ?

berikut code nya

----------employee_controller----------
def live_search
    @phrase = request.raw_post || request.query_string
    a1 = "'%"
    a2 = "%'"
    @searchphrase = a1 + @phrase + a2
    @results = Sheet.find(:all, :conditions => [ "activity_desc LIKE
?", @searchphrase])
    @number_match = @results.length   
    render(:layout => false)
  end
---------------------------------------

------------search.rhtml---------------
<%= javascript_include_tag "prototype" %>
<%= start_form_tag({:action=> "search"}, { :onSubmit =>
"Element.show('spinner');" }) %>
<table>
<tr>
<td><label for="searchtext"><font size="1"><b>Search
timesheet:</b></font></label></td>
<td><%= text_field_tag :searchtext %></td>
<td><img alt="spinner" id="spinner" src="/images/spinner.gif"
style="display:none;" /></td>
</tr>
</table>
<%= end_form_tag%>

<%= observe_field(:searchtext,
                 :frequency => 0.5,
                 :update => :search_hits,
                 :loading => "Element.show('spinner')",
                 :complete => "Element.hide('spinner')",                 
                 :url => { :action => :live_search }) %>

<div id="search_hits"></div>
---------------------------------------

-------------live_search.rhtml------------
<% if @results.empty? %>
  '<%=h @phrase %>' not found!
<% else %>
  '<%=h @phrase %>' found <b><%= @number_match %></b> time(s)!
<% end %>
------------------------------------------


Kind regard


Farid

Kirim email ke