2

I've been trying to make a paragraph in this little piece of code:

flash[:error] = "ATENÇÃO!\nNenhum dos campos pode ser deixado em branco"

right where the \n is, but when I render it on my ruby application it doesn't seem to make a paragraph any help/ideas?

2 Answers2

3

In HTML you need <br />

"ATENÇÃO!<br />Nenhum dos campos pode ser deixado em branco"

And render your flash message like

flash[:error].html_safe
Ursus
  • 29,643
  • 3
  • 33
  • 50
1

You can still use \n and handle the break with CSS, like this:

erb

<div class="new-line"><%= flash[:error] %></div>

style

<style type="text/css">
  .new-line {
    white-space: pre-wrap;
  }
</style>

With that styling in place, \n will behave as <br>.

Gerry
  • 10,337
  • 3
  • 31
  • 40