Does collection_select work in list.rhtml?

Hi,
I have 2 models:
Model 1: er, Columns: <er_id, er_name>
Model 2: er_process, Columns: <er_id, er_process_name>
er_id is a foreign key for Model 2.

When I am creating a new er_process or editing an existing one, I have
been successful to use collection_select to show the available er’s so
that the user can select a particular er by its name (to populate the
er_id field of er_process), like this:

<% form_tag({:action => ‘create’}) do -%>
ER ID:
<%= collection_select (“er_process”, “er_id”, Er.find(:all),
“er_id”, “er_name”) %>

<% end %>

But I have failed to do a similar thing in my list.rhtml page for
er_process. What I need is, provide the user with a ‘filter’ so that
only the listing (of er_process) with a particular er_id is shown,
based on what the user has selected as ‘er_id’. I used this in my
list.rhtml:

<% form_tag({:action => ‘search’}) do -%>
<%= collection_select (“er_process”, “er_id”, Er.find(:all),
“er_id”, “er_name”) %>
<%= submit_tag(‘Filter by ER’) %>

<% end %>

(I have a method ‘search’ in my controller that works fine).

The above is not working, giving me the error:
undefined method `er_id’ for #Array:0x4a78178

To my surprise, a text_field_tag is working:
<%= text_field_tag :er_id, @er_id, :size => 1 %>

But this doesn’t fulfill my need as I want the user to select from a
drop-down-list (using collection_select).

Could anybody please help?
Thanks.

Hello,
I’have the same problem , Have you found a solution . If you have
please post.
Meanwhile I’m trying to use aax to solve the problem…

found a solution

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/e0e3e414ce943cc4/402ca7bac08abee3?lnk=gst&q=list+editing&rnum=8#402ca7bac08abee3

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs