Rails 3: How to display properly text from “textarea”?

Rails got a helper method out of the box, so you dont have to write your own method.

From the documentation:

simple_format(text, html_options={}, options={})

my_text = "Here is some basic text...\n...with a line break."

simple_format(my_text)
# => "<p>Here is some basic text...\n<br />...with a line break.</p>"

more_text = "We want to put a paragraph...\n\n...right there."

simple_format(more_text)
# => "<p>We want to put a paragraph...</p>\n\n<p>...right there.</p>"

simple_format("Look ma! A class!", :class => 'description')
# => "<p class="description">Look ma! A class!</p>"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)