# Observe\_field value in controller

**URL:** <https://www.ruby-forum.com/t/observe-field-value-in-controller/171832>\
**Category:** Rails\
**Created:** [July 9, 2009, 9:44pm UTC](https://www.ruby-forum.com/t/observe-field-value-in-controller/171832 "2009-07-09T21:44:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mistressjanna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mistressjanna](https://www.ruby-forum.com/u/mistressjanna)\
**Post date:** [July 9, 2009, 9:44pm UTC](https://www.ruby-forum.com/t/observe-field-value-in-controller/171832/1 "2009-07-09T21:44:25Z")

</div>

how do I access the value of the field referenced in observe\_field  
from within my controller for the action specified?

I have a select with id “channelnotes” on it, to which I have an  
observe\_field that correctly works in calling channels.notesboxchange.  
In my controller, I am trying to pick up the value of the select from  
puts params[‘channelnotes’] and puts params[:channelnotes] and getting  
nil, even when the select has text selected in it.

I must be doing something stoopid. Below is my .html.erb, as well as  
the html/js produced by it. Thanks, Janna B.

\<% form\_for :associates, :html =\> {:name =\> ‘upsform’,:id =\>  
‘upsform’},:url=\>{ :action =\>“uplog\_update\_form”, :controller  
=\>“channels”} do |f| %\>

Notes: Subrata Chakrabarty Tiger Software India
\<%= observe\_field "channelnotes", :url =\> {:controller =\> :channels, :action =\> 'notesboxchange'} %\>

Notes: Subrata Chakrabarty Tiger Software India
//\<![CDATA[new Form.Element.EventObserver('channelnotes', function(element, value) {new Ajax.Request('/channels/notesboxchange', {asynchronous:true, evalScripts:true, parameters:value + '&authenticity\_token=' + encodeURIComponent('S7PkvbfwdF+Da2/ PbRUKW0YThoCF+qMynOAJyQoOi3c=')})}) //]]\> \</script\>

---

<div class="post-metadata">

**Author:** ![mistressjanna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mistressjanna](https://www.ruby-forum.com/u/mistressjanna)\
**Post date:** [July 10, 2009, 1:31am UTC](https://www.ruby-forum.com/t/observe-field-value-in-controller/171832/2 "2009-07-10T01:31:41Z")

</div>

On Thu, 2009-07-09 at 12:43 -0700, JannaB wrote:

> how do I access the value of the field referenced in observe\_field  
> from within my controller for the action specified?

> \<%= observe\_field “channelnotes”,  
> :url =\> {:controller=\> :channels, :action =\> ‘notesboxchange’}  
> :with =\> whatever\_you\_want\_the\_parameter\_key\_to\_be\_named  
> %\>

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![mistressjanna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mistressjanna](https://www.ruby-forum.com/u/mistressjanna)\
**Post date:** [July 10, 2009, 2:10am UTC](https://www.ruby-forum.com/t/observe-field-value-in-controller/171832/3 "2009-07-10T02:10:13Z")

</div>

THanks Bill, yes it works now as:

\<%= observe\_field “channelnotes”,
