in Ruby on Rails

Resizing the Width of a Text_area (Rails/Bootstrap)

So on one of my personal projects I’m working on I have an input area that is used for blog posts. The default “text_area” in Rails is small. Certainly not a box big enough for your typical blog post. Of course one can resize this manually in one’s browser. However, I’m building this to make some easy enough my Grandma could use.

At first I simply tried changing it from:

to

Now, this worked great for the rows. It changed to this giant rectangle standing on its side. Unfortunately the columns didn’t change. I did some Googling and came across a few outdated Questions/Answers on Stackoverflow about this same incident. However, most of the solutions there no longer worked with the latest versions of Ruby on Rails and Twitter Bootstrap.

Luckily I discovered that you can pass a class into a text_area. Earlier I was trying to use :input_html but that seemed to not work. Below is the code that was able to change the size of my columns.

Notice that I have a div class of “span12” and then inside that is the text_area which has it’s own class of “span6”. This is based on the Twitter Bootstrap grid system. Please note I’m not saying these dimensions look good, or are what I’m actually going to use, but using this method to size your text_area is great because now the box is fluid and changes with the size of the browser. This was a much simpler way of changing the size of my text_area than modifying my CSS files.

Write a Comment

Comment