Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the textarea helper in Rails forms

Why does this code show an error in text area?

<%= form_for(:ad, :url => {:action => 'create'}) do |f| %>
  <%= f.text_field(:name) %>
  <%= f.text_area_tag(:text, "", :size => "50x10") %>
  <%= submit_tag("Submit") %>
<% end %>
like image 978
maria Avatar asked Nov 10 '10 03:11

maria


1 Answers

The FormHelper method is text_area, not text_area_tag.

Use either of the following:

<%= f.text_area(:text, size: '50x10') %>

or:

<%= text_area_tag(:ad, :text, size: '50x10') %>
like image 146
meagar Avatar answered Oct 04 '22 13:10

meagar