Collection_select and Ajax

(I posted this earlier but it doesn’t appear on the group, so I’m
writing it again, If it appears twice, I apologize.)

I have a drop-down box that allows the user to select a language. I want
to use Ajax to render a filtered list of items based on the language
selected. I don’t want the user to press a Submit button nor refresh the
page, of course.

I have it working, but my solution ugly so I believe I’m not doing it
the proper Rails way.

I’m using the standard collection_select in my view:

<%= collection_select (‘item’, ‘language_id’, @languages, ‘id’, ‘lang’,
{}, { :id => ‘lang_select’ } ) %>
<%= observe_field( ‘lang_select’,

%>

This renders as follows:

English

Spanish French

The problem is that the following are the params that Ajax is sending
back to my controller when the user selects a different language:

action: filter_by_language
controller: items
“2”: “”

As you can see, rather than the selected value (2 in this case) being
attributed to a param, the param itself is named after the value. What I
want it to be is something like this:

“item[language_id]”: “2”
or
“lang_select”:“2”

As it is, I have a loop in the controller that checks for the existance
of a parameter for each language_id, but that feels ugly, so I’m sure I
must be doing something wrong, but what I don’t know.

Any help is appreciated. Thanks.