# Select option passes value =\> nil, not name =\> value

**URL:** <https://www.ruby-forum.com/t/select-option-passes-value-nil-not-name-value/129787>\
**Category:** Rails\
**Created:** [February 21, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/select-option-passes-value-nil-not-name-value/129787 "2008-02-21T15:59:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [February 21, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/select-option-passes-value-nil-not-name-value/129787/1 "2008-02-21T15:59:08Z")

</div>

Hello. I’m trying to have a select box in one of my views be observed  
for change and have the value of the select box be accessible via  
params[:name] in my controller. However, no matter what I try the select  
parameters sent back to the server are always in params as “value =\>  
nil”. That makes it quite difficult to get the value of the select box  
since value is different for every selection.

Here is what I’ve tried.

1. Simple HTML approach

 Bald Eagle \<%= observe\_field("bird", :url =\> url(:avian, :hunt)) %\>
1. Rails approach

\<%= collection\_select(“avian”, “avian\_id”, Avian.find(:all).sort,  
:avian\_id, :description, :include\_blank =\> true) %\>  
\<%= observe\_field(“avian\_avian\_id”, :url =\> url(:avian, :hunt)) %\>

In case 1 the parameters related to the select that appear with params  
are “3 =\> nil”. Similar feedback for case 2. In neither case is the  
select in a form. I figured that is not necessary since my HTML is valid  
and the observer is monitoring the select. I’ve tried wrapping the  
select in a simple but no luck.

Obviously I am missing something because I cannot find posts related to  
this topic in this forum or elsewhere on the 'net. I’m trying to take  
the simplest approach here. Can someone please clue me in? Thanks!

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [February 21, 2008, 9:30pm UTC](https://www.ruby-forum.com/t/select-option-passes-value-nil-not-name-value/129787/2 "2008-02-21T21:30:31Z")

</div>

Have u tried using the :with argument?

\<%= observe\_field ‘avian\_avian\_id’,  
:url =\> url(:avian, :hunt),  
:with =\> ‘name’ %\>

[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000966](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000966)

Regards,  
Jabbslad

On Feb 21, 2:59 pm, Chris S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [February 22, 2008, 4:52am UTC](https://www.ruby-forum.com/t/select-option-passes-value-nil-not-name-value/129787/3 "2008-02-22T04:52:03Z")

</div>

That did the trick, thank you.
