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 -%> <label for="er_id">ER ID: </label> <%= 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -%> <label for="er_id">ER ID: </label> <%= 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
found a solution http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/e0e3e414ce943cc4/402ca7bac08abee3?lnk=gst&q=list+editing&rnum=8#402ca7bac08abee3 On 3 Ago, 20:09, Niaz Arifin <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 oreditingan 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 -%> > <label for="er_id">ER ID: </label> > <%= collection_select ("er_process", "er_id", Er.find(:all), > "er_id", "er_name") %> > ... > <% end %> > > But I have failed to do a similar thing in mylist.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 mylist.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. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---