I need to add a line break into a flash notice. So far I have this
flash[:success] = "We will notify you when we go LIVE! #{<br />} Meantime, complete this quick survey so we can get to know your interest.
But it is incorrect. Does anyone know how to properly do this in the controller?
I am using ruby 2.2.1p85 & Rails 4.0.10
There is always a dirty way to do stuff in programming. Here you can create multi line array inside flash.
flash[:success] = []
flash[:success] = flash[:success] << "We will notify you when we go LIVE! "
flash[:success] = flash[:success] << "Meantime, complete this quick survey so we can get to know your interest."
and display it like this
<% flash.each do |key, value| %>
<% value.each do |text| %>
<%= content_tag :div, text %>
<% end %>
<% end %>
This will definitely work.
But the best way to do that is this
flash[:success] = "We will notify you when we go LIVE! <br> Meantime, complete this quick survey so we can get to know your interest.".html_safe
If this also doesn't work then try it another way
in controller set
flash[:success] = "We will notify you when we go LIVE! <br> Meantime, complete this quick survey so we can get to know your interest."
and in view display like
<% flash.each do | value| %>
<%= content_tag :div, value.html_safe %>
<% end %>
flash[:success] = "We will notify you when we go LIVE! <br> Meantime, complete this quick survey so we can get to know your interest."
redirect_to YOUR_URL, flash: { html_safe: true }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With