Text_area_for

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

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 it’s
more geared towards sharing the new and edit forms, but hopefully will
provide some clarity :slight_smile: