# Strange error: Could anybody please help?

**URL:** <https://www.ruby-forum.com/t/strange-error-could-anybody-please-help/109774>\
**Category:** Rails\
**Created:** [July 18, 2007, 11:31pm UTC](https://www.ruby-forum.com/t/strange-error-could-anybody-please-help/109774 "2007-07-18T23:31:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/74df32/32.png) [@arif](https://www.ruby-forum.com/u/arif)\
**Post date:** [July 18, 2007, 11:31pm UTC](https://www.ruby-forum.com/t/strange-error-could-anybody-please-help/109774/1 "2007-07-18T23:31:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![arif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/74df32/32.png) [@arif](https://www.ruby-forum.com/u/arif)\
**Post date:** [July 19, 2007, 12:33am UTC](https://www.ruby-forum.com/t/strange-error-could-anybody-please-help/109774/2 "2007-07-19T00:33:50Z")

</div>

> 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
