2

I'm trying to put a simple smiley into a flash message like so:

flash[:info] = "Please check your email to activate your account ☺"

from the controller

if @user.save      
   flash[:info] = "Please check your email to activate your account ☺"

How do I get ruby to execute this code, it worked right then as I typed the question, but on my rails app not so lucky. I am rendering my flash as a partial on the application.html.haml page that simply loops through the flash messages and displays the message.

_flash.html.haml:

-flash.each do |message_type, message|
    =content_tag(:div, message, class: "alert alert-#{message_type}")
potashin
  • 44,205
  • 11
  • 83
  • 107
Spencer Hire
  • 735
  • 3
  • 14
  • 32

1 Answers1

3

You can use sanitize() to render html entity instead of escaping it:

=content_tag(:div, sanitize(message), class: "alert alert-#{message_type}", escape: false)
potashin
  • 44,205
  • 11
  • 83
  • 107