Help with simple_format and line breaks

Hello Ruby forum,
I’ve been looking at the other threads before posting this, but I can’t
find a good solution to the problem I’m having.

The problem: in one of my views, I have the following code:

<% for column in BlogPost.content_columns %>

<%=h(simple_format(blog_post.send(column.name))) %>
<% end %>

This does exactly what it’s supposed to do - it preserves the line
breaks and carriage returns entered into my text fields by adding

,
and suchlike. But that's all it does. If I entered:

“Please
have
a nice day”

into the “body” text field of my blog engine, I would get:

“Please

have

a nice day”

back (I left some HTML code out, but you get the idea).

How do I get back exactly what I entered? If you answer, would you mind
posting some code? I still haven’t seen a code example that solves this
problem. Thanks in advance!

onemind wrote:

How do I get back exactly what I entered? If you answer, would you mind
posting some code? I still haven’t seen a code example that solves this

This is without code… Sorry :wink:
Have a look at the incoming posting. If you enter the message directly
into your database, it wont have any line breaks at all. If a message
comes from a textfield on your page it will contain line breaks like
“\n”.

bye.
andreas

Andreas wrote:
Have a look at the incoming posting. If you enter the message directly
into your database, it wont have any line breaks at all. If a message
comes from a textfield on your page it will contain line breaks like
“\n”.

Hi andreas,
I feed the text into the database from a :text field in my view. I
looked at what was stored in my tables, and it looks like it has line
breaks. They just don’t show up in my UI. Any insights?

Thank you,
onemind

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs