我正尝试在Flash消息中添加一个简单的笑脸,如下所示:
flash[:info] = "Please check your email to activate your account ☺"
从控制器
if @user.save
flash[:info] = "Please check your email to activate your account ☺"
我如何获得ruby来执行此代码,当我键入问题时,它就可以正常工作了,但是在我的Rails应用程序上却没有那么幸运。我将flash呈现为application.html.haml页面上的一部分,该页面只是循环浏览flash消息并显示该消息。
_flash.html.haml:
-flash.each do |message_type, message|
=content_tag(:div, message, class: "alert alert-#{message_type}")
您可以使用sanitize()
渲染html实体而不是将其转义:
=content_tag(:div, sanitize(message), class: "alert alert-#{message_type}", escape: false)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句