Dumb newbie question - text formatting?


#1

I have a MySQL “text” element that I’m trying to display, but it’s not
formatting (i.e. it’s all one big paragraph). In the AWD depot example
it doesn’t look like they do anything special, but they get formatted
text. I’ve tried it with both:

<%= show.description %> - puts text, and formats according to any HTML
tags I typed in.

and

<%= h(show.description) %> - puts text and HTML tags, no formatting.

What am I missing?

Thanks,

Adam


#2

Hi Adam,

Try simple_format, shown here:
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M00051
3

This page also has other helpful text helpers

Daniel


#3

Daniel H. wrote:

Hi Adam,

Try simple_format, shown here:
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M00051
3

This page also has other helpful text helpers

Daniel

That’s awesome. Thanks.

-Adam


#4

Adam B. wrote:

<%= h(show.description) %> - puts text and HTML tags, no formatting.

What am I missing?

In the depot example Dave T. was using HTML tags to format his
descriptions (and that’s why he didn’t use h() to escape them).

regards

Justin