# Text\_area\_for

**URL:** <https://www.ruby-forum.com/t/text-area-for/127744>\
**Category:** Rails\
**Created:** [January 31, 2008, 9:31pm UTC](https://www.ruby-forum.com/t/text-area-for/127744 "2008-01-31T21:31:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![philthompson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@philthompson](https://www.ruby-forum.com/u/philthompson)\
**Post date:** [January 31, 2008, 9:31pm UTC](https://www.ruby-forum.com/t/text-area-for/127744/1 "2008-01-31T21:31:53Z")

</div>

Hi,

I have a form on a page which consists of a bunch of \<%= text\_field\_for  
blah blah blah %\> tags. One of them will contain a lot of text over  
multiple lines, surely it’s possible to do a \<%=text\_area\_for  
blahblahblah%\> ??? I can’t seem to find the correct syntax. I keep  
getting undefined method text\_area\_for…

any ideas?

cheers,

phil

---

<div class="post-metadata">

**Author:** ![philthompson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@philthompson](https://www.ruby-forum.com/u/philthompson)\
**Post date:** [January 31, 2008, 9:57pm UTC](https://www.ruby-forum.com/t/text-area-for/127744/2 "2008-01-31T21:57:38Z")

</div>

Rather then using text\_field\_for, you should use the syntax favoured by  
Rails 2.0 (which I presume you’re using)–start your form with:

form\_for(@article) do |f|

Then you can write things like this:

f.text\_field :title # creates a text-field mapped to the title attribute  
of the model  
f.check\_box :is\_published  
f.submit “Register Me!”

And, of course, the one you asked for:

f.text\_area :comments, :cols =\> 60

Best of all, Rails will handle the mapping to the model, and even  
putting in data (say, when you edit the form)

I wrote an article on forms in Rails here:  
[Railsrocket.com is for sale | HugeDomains](http://www.railsrocket.com/sharing-new-and-edit-forms-with-partials) it’s  
more geared towards sharing the new and edit forms, but hopefully will  
provide some clarity 🙂
