0

I currently have a .text_area (controller.notes) input field on my form. When I open the form it shows the leading white space between lines like so:

I am a line

I am the next line

However, when I render a table with

<tbody>
  <% @controller.where(:column => "status1").order([:status, :date]).each do order %>
    <tr>
      <td><%= controller.notes %></td>
    </tr>
  <% end %>
</tbody>

it is stripping the white space in the .notes, not showing line breaks people put in with enter. How can I get it to show the line breaks? I tried <pre> tag, but that doesn't work right as it turns off the text wrapping wrapping.

It doesn't have the -%> on the end that would tell ERB to strip the white space, so I don't know why it is.

I do have twitter bootstrap installed and I am using the tables within it; I just don't see anything in the CSS that would cause it at this point. I am only using text-align: center; for the td tag.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Shenanigator
  • 1,036
  • 12
  • 45
  • I think this one has been covered: https://stackoverflow.com/questions/3137393/rails-add-a-line-break-into-a-text-area – Tim Jan 06 '16 at 21:25
  • I am not sure, but you can try sanitize of directly html_safe on controller.notes – dsounded Jan 06 '16 at 21:25
  • Actually, Tim, that was one of the first things I looked at and it did not apply to my particular problem. My problem was the line breaks should have been there and weren't showing; I was not missing line breaks. See the solution below. – Shenanigator Jan 07 '16 at 16:47

1 Answers1

0

I found it; it was CSS, but not CSS I was using. CSS I wasn't using.

style="white-space: pre-line;" works for just that specific field.

if you want to do it in your CSS file you can use white-space: pre-line; in the proper CSS field.

Shenanigator
  • 1,036
  • 12
  • 45