# Strange error: Could anybody please help?

**URL:** <https://discuss.rubyonrails.org/t/strange-error-could-anybody-please-help/15822>\
**Category:** rubyonrails-talk\
**Created:** [July 18, 2007, 5:32pm UTC](https://discuss.rubyonrails.org/t/strange-error-could-anybody-please-help/15822 "2007-07-18T17:32:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arif](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Arif](https://discuss.rubyonrails.org/u/Arif)\
**Post date:** [July 18, 2007, 5:32pm UTC](https://discuss.rubyonrails.org/t/strange-error-could-anybody-please-help/15822/1 "2007-07-18T17:32:57Z")

</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 (list.rhtml): &nbsp;&nbsp;&nbsp;&nbsp;\<% @sac\_database.each do |c| %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= c.database\_name -%\> &nbsp;&nbsp;&nbsp;&nbsp;\<% 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: &nbsp;&nbsp;&nbsp;&nbsp;\<%= start\_form\_tag :action =\> 'search' %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= text\_field "sac\_database", "database\_name", "size" =\> 20 %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= submit\_tag 'Search' %\> &nbsp;&nbsp;&nbsp;&nbsp;\<%= end\_form\_tag %\>

It gives me this error: undefined method `database\_name' for #\<Array:0x4b95920\>

I have tried many possibilities, like &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= 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:** ![Philip\_Hallstrom1](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@Philip\_Hallstrom1](https://discuss.rubyonrails.org/u/Philip_Hallstrom1)\
**Post date:** [July 18, 2007, 10:17pm UTC](https://discuss.rubyonrails.org/t/strange-error-could-anybody-please-help/15822/2 "2007-07-18T22:17:45Z")

</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): &nbsp;&nbsp;&nbsp;\<% @sac\_database.each do |c| %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= c.database\_name -%\> &nbsp;&nbsp;&nbsp;\<% 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: &nbsp;&nbsp;&nbsp;\<%= start\_form\_tag :action =\> 'search' %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= text\_field "sac\_database", "database\_name", "size" =\> 20 %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= submit\_tag 'Search' %\> &nbsp;&nbsp;&nbsp;\<%= 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
