Using the textarea helper in Rails forms

maria picture maria · Nov 10, 2010 · Viewed 23.3k times · Source

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 %>

Answer

meagar picture meagar · Nov 10, 2010

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') %>