Hi, I have a RAILS model named ''sac_database'' with a column ''databae_name''. It works fine when I try to show the records found from my database, for example, this works fine in my view (list.rhtml): <% @sac_database.each do |c| %> <%= c.database_name -%> <% end %> But, I need to add a text_field for the column ''databae_name'' (in order to search), and I tried something like this in my view: <%= start_form_tag :action => ''search'' %> <%= text_field "sac_database", "database_name", "size" => 20 %> <%= submit_tag ''Search'' %> <%= end_form_tag %> It gives me this error: undefined method `database_name'' for #<Array:0x4b95920> I have tried many possibilities, like <%= text_field params[:sac_database], params[:database_name], "size" => 20 %> but none was successful. Could anybody point to where the problem is with this simple text_field tag? Any help would be greatly appreciated. Thanks, Arif --~--~---------~--~----~------------~-------~--~----~ 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 a RAILS model named ''sac_database'' with a column ''databae_name''. It works fine when I try to show the records found from my database, for example, this works fine in my view (list.rhtml): <% @sac_database.each do |c| %> <%= c.database_name -%> <% end %> But, I need to add a text_field for the column ''databae_name'' (in order to search), and I tried something like this in my view: <%= start_form_tag :action => ''search'' %> <%= text_field "sac_database", "database_name", "size" => 20 %> <%= submit_tag ''Search'' %> <%= end_form_tag %> It gives me this error: undefined method `database_name'' for #<Array:0x4b95920> I have tried many possibilities, like <%= text_field params[:sac_database], params[:database_name], "size" => 20 %> but none was successful. Could anybody point to where the problem is with this simple text_field tag? Any help would be greatly appreciated. Thanks, Arif -- 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 -~----------~----~----~----~------~----~------~--~---
> Hi, > I have a RAILS model named ''sac_database'' with a column > ''databae_name''. It works fine when I try to show the records found > from my database, for example, this works fine in my view > (list.rhtml): > <% @sac_database.each do |c| %> > <%= c.database_name -%> > <% end %> > > But, I need to add a text_field for the column ''databae_name'' (in > order to search), and I tried something like this in my view: > <%= start_form_tag :action => ''search'' %> > <%= text_field "sac_database", "database_name", "size" => 20 %> > <%= submit_tag ''Search'' %> > <%= end_form_tag %> > > It gives me this error: > undefined method `database_name'' for #<Array:0x4b95920>Assuming both of the above are in the same view, @sac_database is an array of SacDatabase objects. You''re call to text_field expects to find a valid @sac_database of *type* SacDatabase. Can''t suggest how you want to fix it since I don''t know what you''re doing, but that''s the problem. If it were me, I''d change your controller to return @sac_databases (note the s) for the array of SacDatabase objects and also set @sac_database for use in your form to whichever one you want. -philip> > I have tried many possibilities, like > <%= text_field params[:sac_database], params[:database_name], > "size" => 20 %> > but none was successful. > > Could anybody point to where the problem is with this simple > text_field tag? > Any help would be greatly appreciated. > Thanks, > Arif > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---