# Observe\_field and disptcher problem

**URL:** <https://www.ruby-forum.com/t/observe-field-and-disptcher-problem/155317>\
**Category:** Rails\
**Created:** [December 10, 2008, 3:37pm UTC](https://www.ruby-forum.com/t/observe-field-and-disptcher-problem/155317 "2008-12-10T15:37:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gpierce](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/90ced4/32.png) [@gpierce](https://www.ruby-forum.com/u/gpierce)\
**Post date:** [December 10, 2008, 3:37pm UTC](https://www.ruby-forum.com/t/observe-field-and-disptcher-problem/155317/1 "2008-12-10T15:37:57Z")

</div>

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](http://localhost/transactions/search_list?text=gregauthenticity_token=484c0acdba12c67bfd3e842206db6fa122163fca)]

Any suggestions?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![gpierce](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/90ced4/32.png) [@gpierce](https://www.ruby-forum.com/u/gpierce)\
**Post date:** [December 11, 2008, 6:01am UTC](https://www.ruby-forum.com/t/observe-field-and-disptcher-problem/155317/2 "2008-12-11T06:01:58Z")

</div>

hi,

i am very new to rails but i have implemented live search using ajax  
the same way you tried .

try this out:but i am not sure

def search\_list  
if params[:text]  
@transactions = Transaction.find(:all, :order =\> “created\_at  
DESC”, :conditions =\> [ ‘LOWER(name) LIKE ?’, ‘%’ +  
params[:text].downcase + ‘%’ ]).reverse  
else  
flash[:notice] = ‘not found.’

```
 render :partial => 'transactions_list'

```

else  
render :partial =\> ‘index’  
end  
end

thnaks  
srikanth

On Wed, Dec 10, 2008 at 8:07 PM, Gregory P.
