1

I'd like to use a long message on the flash notice of success when user confirms. So i'd like to display it on 2 lines using a <br/> on devise.en.yml

How/Where can I raw or use another method to do it ?

Here is my yml

en:
  devise:
    confirmations:
      confirmed: "Just confirmed loremp ipsum !!!!! !<br/> To start you up, you get full access to the website for 3 days lorem ipsum lorem ipsum lorem ipsum"

I tried to use raw here on my flash message

<!-- Flash messages to display alerts and notices (including success messages) -->

<% flash.each do |name, msg| %>
  <% if msg.is_a?(String) %>
    <div class="alert alert-<%= name == :notice ? "success" : "error" %>">
      <a class="close" data-dismiss="alert">&#215;</a>
      <%=raw content_tag :div, msg, id:"flash_#{name}" %>
    </div>
  <% end %>
<% end %>

But the flash message does not understand/interpret my <br/> and just writes on the page <br/>

user229044
  • 232,980
  • 40
  • 330
  • 338
Mathieu
  • 4,587
  • 11
  • 57
  • 112
  • Isn't there a String attribute in Rails, that makes it decide whether a String object is safe or not? If so, have you tried marking the caption as safe? – Denis de Bernardy Jun 26 '13 at 20:54
  • i'm a newbie so i don't really understand what you say. I usually use <%=raw t(" ") %> when i want ton include html format markups such as < b/ > or < br/ > inside my yml files and it usually works. But here it's a specific problem: on devise flash message, my markup is not interpreted. – Mathieu Jun 26 '13 at 20:58
  • @Denis how do you mark a caption as safe ? – Mathieu Jun 26 '13 at 20:59
  • it looks like it's `html_safe`: http://stackoverflow.com/questions/7300901/marking-a-string-as-html-safe – Denis de Bernardy Jun 26 '13 at 21:05

2 Answers2

1

Name the key confirmed_html or use the .html_safe method.

snøreven
  • 1,904
  • 2
  • 19
  • 39
0

Most likely content_tag is sanitizing html tags. Try:

<div id="flash_#{name}">
  <%= raw msg %>
</div>
gylaz
  • 13,221
  • 8
  • 52
  • 58
  • It does work interpreting the < br/> But the problem is i remove 'msg' from <%=raw content_tag :div, msg, id:"flash_#{name}" %> and put it after like: <%= content_tag :div, id:"flash_#{name}" %><%= raw msg %>, then I end up with this flash message: “{:id=>"flash_notice"}Just confirmed loremp ipsum !!!!! ! To start you up, you get full access to the website for 3 days lorem ipsum lorem ipsum lorem ipsum” I don”t want to see {:id=>"flash_notice"}:( – Mathieu Jun 26 '13 at 21:16
  • Note that in my example I'm not using `content_tag`. – gylaz Jun 26 '13 at 22:03