views:

125

answers:

2

I am getting a bug when I use a text_area in my rails app. The box takes line breaks, and makes them indentation. Here is a screen shot, any idea where these indentations are coming from?

https://files.getdropbox.com/u/312568/Picture%2031.png

A: 

Maybe try trimming your text using .strip

  str.strip => new_str

Returns a copy of str with leading and trailing whitespace removed.

   "    hello    ".strip   #=> "hello"
   "\tgoodbye\r\n".strip   #=> "goodbye"

If it doesn't work, I'll need more code to assist you

marcgg
A: 

I had this problem with some early versions of the haml plugin. If you are saying:

= f.text_area :body

you might try

~ f.text_area :body

instead. This invokes whitespace preservation, which is nice for user-entered text.

austinfromboston