How do I change the text_area default size for a form in rails 3?

ajivani picture ajivani · Nov 6, 2010 · Viewed 9.8k times · Source

I'm going through Agile Web Development with Rails and I'm having some trouble with the form helper text_area. Specifically, I want to make the text area smaller (the form submits correctly and everything goes into the database correctly). According to the book this code should work:

<%= form_for(@request) do |f| %>
 <div class="actions">
...
  <div class="field">
<%= f.label :quote_details, "*Items required:" %>
<%= f.text_area :quote_details, :rows=>5, :cols=>40 %>
</div>

It seems that no matter what numbers I put for :rows or :cols, the box stays the same default size. Instead of :rows and :cols, I used :size=>"3x40" and size=>"5x8" etc.. but the box still always stays the same size.

As an experiment I tried

<%= f.text_field :quote_details, :size=>"300*39" %>

That changed the number of columns, but removing the :size and putting :rows or :cols has no effect (it goes back to a default size for a text_field).

I did see this: Change default Rails text_area helper rows/cols I tried answer 1, but the answer given didn't work for me. I don't really understand what the second and third answers mean. I might be doing something else wrong or maybe it's a different problem.

I'm just stumped. Any help or ideas on what's going on would be greatly appreciated. Thanks for any responses.

Oh, I'm using rails version 3.0.0 and ruby 1.9.2p0 on vista.

Answer

nonopolarity picture nonopolarity · Nov 6, 2010

your first code segment has :cols => 40% instead of 40?

I would also consider using CSS to do it, as that can make changing the look of the webpage isolated to the CSS presentation layer.