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

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!

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

Regards,
Jabbslad

On Feb 21, 2:59 pm, Chris S. [email protected]

That did the trick, thank you.