Strange error: Could anybody please help?

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 (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

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