# Asking for help with select form helper and observe\_field

**URL:** <https://www.ruby-forum.com/t/asking-for-help-with-select-form-helper-and-observe-field/124747>\
**Category:** Rails\
**Created:** [January 2, 2008, 6:28am UTC](https://www.ruby-forum.com/t/asking-for-help-with-select-form-helper-and-observe-field/124747 "2008-01-02T06:28:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [January 2, 2008, 6:28am UTC](https://www.ruby-forum.com/t/asking-for-help-with-select-form-helper-and-observe-field/124747/1 "2008-01-02T06:28:17Z")

</div>

I have a select form helper and an observe\_field that’s observing the  
select and calling an action when the select changes. However, I’m  
having trouble passing the right parameters from the select.

The select helper is inside of a form\_for and looks like:  
f.select(:name, @books)

The observe\_field looks like:  
observe\_field :id, :url =\> { :action =\> ‘index’ }

When the post request occurs, I see that the right value parameter  
from the select is passed, but is of the form: value =\> nil, which I  
can’t work with.

Can someone lend me a hand?

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [January 2, 2008, 6:32am UTC](https://www.ruby-forum.com/t/asking-for-help-with-select-form-helper-and-observe-field/124747/2 "2008-01-02T06:32:57Z")

</div>

you’re observing the wrong field? You’re specifying :id in your  
observe\_field (in the example you gave us)

The correct way to do that is:

observe\_field(“object\_name”, :url =\> { :action =\> ‘index’ })

How are you specifying the ID for the object? I’m guessing you didn’t  
specify just :id for it 🙂

On Jan 2, 2008 3:57 PM, eggman2001 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> When the post request occurs, I see that the right value parameter  
> from the select is passed, but is of the form: value =\> nil, which I  
> can’t work with.
> 
> Can someone lend me a hand?
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [January 2, 2008, 6:37am UTC](https://www.ruby-forum.com/t/asking-for-help-with-select-form-helper-and-observe-field/124747/3 "2008-01-02T06:37:03Z")

</div>

On Jan 1, 2008, at 9:27 PM, eggman2001 wrote:

> When the post request occurs, I see that the right value parameter  
> from the select is passed, but is of the form: value =\> nil, which I  
> can’t work with.
> 
> Can someone lend me a hand?

Try this:

observe\_field ‘books\_name’, :url =\> { :action =\> ‘index’ }

n.b., you’ll have to look at the id in your HTML to make sure  
‘books\_name’ is right, but the documentation on observe\_field is  
specific that the first argument is the DOM id of the field. If you  
are still getting nil values, try a second parameter to the hash:

:with =\> “Form.Element.serialize(‘your\_field\_id’)”

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [January 2, 2008, 6:46am UTC](https://www.ruby-forum.com/t/asking-for-help-with-select-form-helper-and-observe-field/124747/4 "2008-01-02T06:46:24Z")

</div>

Had everything right. I just needed to add the :with option. Thanks!!
