Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

try do it with form_with. For me it works.

<%=form_with, local: true do |form| %>

<%= form.label :comment %>
<%= form.text_area :body, :rows=>10, :cols=>60 %>

<% end %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top