Hello everyone,
I am trying to make live-search list with observe_field and I still have
the problem with invoking the proper action.
Take a look at the following code:
index.html.erb:
------------------------------------------------------------------------
<%= text_field_tag "search" %>
<%= observe_field 'search', :url => {:action => "search_list"},
:frequency => 0.5,
:update => 'transactions_list',
:with => "'text=' + escape(value)"
%>
------------------------------------------------------------------------
transactions_controller.rb:
------------------------------------------------------------------------
def search_list
if params[:text]
@transactions = Transaction.find(:all, :order => "created_at
DESC", :conditions => [ 'LOWER(name) LIKE ?', '%' +
params[:text].downcase + '%' ]).reverse
render :partial => 'transactions_list'
else
@transactions = Transaction.find(:all, :order => "created_at
DESC").reverse
render :partial => 'transactions_list'
end
end
------------------------------------------------------------------------
When I am trying to type something into the text_field, the framework
invokes "show" action instead of "search_list".
Take a look at the following logs - it doesn't make sense to me.
------------------------------------------------------------------------
Processing TransactionsController#show (for 127.0.0.1 at 2008-12-10
14:58:42) [GET]
Parameters: {"text"=>"greg",
"authenticity_token"=>"484c0acdba12c67bfd3e842206db6fa122163fca",
"id"=>"search_list"}
Rendering transactions/show
Completed in 9ms (View: 4, DB: 0) | 200 OK
[http://localhost/transactions/search_list?text=gregauthenticity_token=484c0acdba12c67bfd3e842206db6fa122163fca]
------------------------------------------------------------------------
Any suggestions?
Thanks in advance
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---